From 574189659969299f901dea7d633e030cae118e31 Mon Sep 17 00:00:00 2001 From: humuhumu33 Date: Tue, 10 Nov 2026 01:49:18 +0000 Subject: [PATCH 1/2] BS-31: the register row, scenario, and case of the canonical lock text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first slice of the project manager as source (#274), on release/v0.4: the row (register 478 -> 479, the §31 table, the RP-07 check and its case), the scenario, the §17.23 prose, the CHANGELOG entry, the README's claim, the CI part, and the case, conformance_bs_31, which holds LockText.tomlString and canonicalLock to config::toml_string and Lock::canonical_bytes on hand-built texts and locks, on every committed lexlean.lock that parses and the texts in them, and on seeded ones, with 18 planted defects each named by its vector. VERIFICATION.md records the first run: the evaluator agrees on 307 and 542 runs, rustc on 2,449, and every plant is detected. Co-Authored-By: Claude Opus 5.5 --- .github/bdd-parts.json | 3 + .github/vv-rows.json | 9 + CHANGELOG.md | 5 + CONFORMANCE.md | 1 + README.md | 4 +- SPEC.md | 18 +- VERIFICATION.md | 45 + crates/conformance/src/cases/bootstrap.rs | 2 + .../src/cases/bootstrap/lock_text.rs | 921 ++++++++++++++++++ crates/conformance/src/cases/repository.rs | 2 +- crates/conformance/tests/conformance.rs | 5 + features/suites/bootstrap.feature | 7 + model/ids.toml | 6 + xtask/src/spec_links.rs | 4 +- 14 files changed, 1026 insertions(+), 6 deletions(-) create mode 100644 crates/conformance/src/cases/bootstrap/lock_text.rs diff --git a/.github/bdd-parts.json b/.github/bdd-parts.json index fe7db0138d..645b591a09 100644 --- a/.github/bdd-parts.json +++ b/.github/bdd-parts.json @@ -37,6 +37,9 @@ "bootstrap-terms": [ "BS-10" ], + "bootstrap-lock-text": [ + "BS-31" + ], "bootstrap-tooling-latex": [ "BS-20" ], diff --git a/.github/vv-rows.json b/.github/vv-rows.json index a0695b8575..3910c86f82 100644 --- a/.github/vv-rows.json +++ b/.github/vv-rows.json @@ -62,6 +62,15 @@ "memory_kib": "", "hints": "" }, + { + "part": "bdd-bootstrap-lock-text", + "recipes": "bdd", + "examples_part": "", + "bdd_part": "bootstrap-lock-text", + "width": "", + "memory_kib": "", + "hints": "" + }, { "part": "bdd-bootstrap-tooling-latex", "recipes": "bdd", diff --git a/CHANGELOG.md b/CHANGELOG.md index 68f6a6eb5e..3a5725f7f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,11 @@ workspace carried at those versions without a tag. ## Unreleased +- The canonical text of the lock file as language-1.2 source (SPEC.md §11.2, + §17.23, `BS-31`, #274; no new diagnostic code, no change to the language-1.2 + identity). `canonicalLock` and `tomlString` of `LockText` return what + `Lock::canonical_bytes` and `config::toml_string` return; neither admits + `recursion`. The register is 479 IDs. - Canonical JSON reading in the standard library, the fourth member the self-hosted compiler needs, #276 (SPEC.md §17.22, `SL-13`). The module `LexLeanStd.JsonRead` holds the production roots `readJson` and diff --git a/CONFORMANCE.md b/CONFORMANCE.md index c9b4937578..4b46f5155d 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -77,6 +77,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `BS-15` | `build` | The package renderer of SPEC.md §17.16 (the checks `package::lower` makes of a manifest's own fields before it reads the program: the spec, the crate name against the Rust keywords and the reserved crates, the version, the profile, the form and the order of the sources, and the effects against the registry, with `allocation` refused on `rust-core`; the Cargo manifest over the scaffold record; and the provenance in canonical JSON with the digests of the runtime, the Cargo manifest, and the library) is language-1.2 source in the `bootstrap/` project, as two production roots of `RustPackage` that the host composes around the roots of `BS-04` to `BS-14`: `checkManifest`, which for the fields of a manifest and the registered effects returns whether the profile is `rust-std`, or the refusal of `package::lower` to the byte, and `renderPackage`, which for the scaffold record, the manifest's name, version, profile, sources, effects and exports, the program's identity, the compiler-semantics identity, the two runtime texts, and the library returns the `Cargo.toml` and the `provenance.json` of `package::package` to the byte; each is eligible for `rust-std` with exactly its declared effects and has no part of its certificate beyond 3,145,728 bytes; the oracle of `checkManifest` is `package::lower` on the manifest with its program and exports replaced by a pair every later check accepts, which agrees with each committed negative manifest's refusal, and the oracle of `renderPackage` is `package::package` on the 299 committed manifests it accepts and, on 137 hand-built inputs (names, exports, sources and effects that reach the escaper, and scaffold records that differ from the committed one) and 299 seeded mutants, `cargo_toml_of` and the canonical JSON of §21.7 by the recipe `package::package` is held to; on the normative host the lowered programs under the calculus evaluator agree with the oracle on the 318 committed manifests, 182 rule manifests and 2,000 seeded mutants, and on the 241 renders whose library is at most 16,384 bytes; the rendered packages agree with the oracle under the pinned rustc on all 3,190 runs; 21 planted defects in the source are each detected; and the certified packages the production export publishes for the project are the committed ones; the checks of the program, the exports and the crate, and the bytes of the library, which are the rows `BS-04` to `BS-14`, are outside the claim. | | `BS-16` | `build` | The GNAF request validation of SPEC.md §17.15 (`gnaf::validate`, with `universe_size`) is language-1.2 source in the `bootstrap/` project: `validateRequest` of `GnafValidate` is a production root eligible for `rust-std` with exactly its declared effects, over the projection of a request that validation reads (the length of the domain, the machine, the carrier's kind with each plan's preparations and the thresholds, the completeness evidence, the objective, the claim's class, and the scope) as first-order data, and returns the first violated rule in the model's order as the oracle's `serde_json` bytes, or nothing; on every host, its rendered `rust-std` package under the pinned rustc agrees with the Rust oracle `gnaf::validate` on the acceptance and on the rejection, to the byte, on the committed requests of `compiler/gnaf/`, the requests the committed certificate fixtures name, hand-built requests that reach each rejection, and seeded mutants of the committed requests; on the normative host, the root's lowered program under the calculus evaluator agrees with the oracle on the same corpus, each planted defect in the source is detected, and the certified package the production export publishes for the project is the committed one; loading a request (`gnaf::load`), the universe identity, the answer, and certification are outside the claim. | | `BS-20` | `build` | The canonical LaTeX of a tooling module of SPEC.md §17.20 (`backend::tooling::render_latex`: the fixed document frame and, for each declaration in order, its title, its kind, and the lines the Lean printer of the same file spells for its types, signatures, and terms, every line escaped by `tex_escape`) is language-1.2 source in the `bootstrap/` project: `renderToolingLatex` of `ToolingLatex`, over the tooling module as first-order data with each list carried as a chain of its own `Nil` and `Cons` constructors and with the typings the checker infers as an argument, writing through the standard library's `Buffer` with an explicit capacity, is a production root eligible for `rust-std` with exactly its declared effects; its rendered `rust-std` package under the pinned rustc and its lowered program under the calculus evaluator agree with the Rust oracle on the text, to the byte, and on the refusal of a write past the capacity, on the committed tooling modules (whose committed `.tex` is equal to the text), on hand-built modules that reach every declaration, type, signature, and term form and every byte class of the escaper, and on seeded mutants, every planted defect is detected, and the certified package the production export publishes for the project is the committed one; the checker, the decoder of the module, and the source map of the emitted pieces stay in the host. | +| `BS-31` | `build` | The canonical text of the lock file of SPEC.md §11.2 (`lock::Lock::canonical_bytes`: the header keys in their fixed order with the lock spec of the language and the pinned Lean toolchain, the workspace pins sorted by path, the packages sorted by identifier and version, the source packages sorted by identifier, and the PDF record with its resources sorted by path, each digest in lower-case hex; and `config::toml_string`: the TOML basic string of a text, with the quote, the backslash, and every control escaped) is language-1.2 source in the `bootstrap/` project, as two production roots of `LockText`: `canonicalLock` and `tomlString`, each eligible for `rust-std` with exactly its declared effects, `allocation` and `overflow`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator, agree with the oracle to the byte on hand-built locks and texts, which reach every table, both lock specs, every order of rows the sort decides, and every class of escape, on every committed `lexlean.lock` that parses and every text in them, and on seeded locks and texts; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; reading a lock, resolving its packages, and hashing its files are outside the claim. | ## calculus diff --git a/README.md b/README.md index 0f5db6830c..1e14e1dca3 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ just vv # the complete normative acceptance gate (SPEC.md §9.2) just release # vv, then the §30 release criterion; refused until 1.0.0 ``` -All 478 registered conformance IDs have their named tests; `just vv` checks them with the pinned toolchain installed. +All 479 registered conformance IDs have their named tests; `just vv` checks them with the pinned toolchain installed. The differential against the independent generator `lean4-prod` (SPEC.md §17.19, `OR-01`..`OR-08`) acquires it at its pinned commit: from the checkout `LEXLEAN_ORACLE_DIR` names, or by fetching the commit with `git` into the Cargo target directory (`LEXLEAN_ORACLE_CACHE` overrides), and builds it with the pinned Lean and Rust toolchains. It is validation evidence only and no input to any identity. An oracle that cannot be acquired, is not the pinned files, or fails is unavailable: that fails the gate on Linux x86-64 and is printed as `NOT VALIDATED` elsewhere, and is never reported as agreement. @@ -197,7 +197,7 @@ Every row is validated by `just vv`; the IDs link the claim to its register row, | The language-1.2 authoring notation: a readable `.lex.tex` text for a semantic module, in bijection with its canonical JSON, whose every position and variant is read from the schema, with readable forms for types and terms and a generic form for every other value, formatted canonically by `fmt` failing closed, the only form in which a language-1.2 source of the product is written (the data form is refused under language 1.2, and `lexlean::sdk` is the explicit conversion), the same for the compiler-tooling modules in the generic notation, with no compiler-semantics ID that depends on which form an embedded module is written in, with no product source owned by a generator but five named records, read and written by programs only through the authoring API (`lexlean::sdk`), and, for a native core module, a readable program over the shared table of kernel terms whose numbering is the order of its text | `AU-01`..`AU-13` | `build` | | The runtime of generated Lean as native modules: the portable, collection, model, and reasoning runtimes of language 1.2 are LexLean source that every generated module imports, migrated losslessly and audited against their exact axioms, the released runtime text of languages 1.0 and 1.1 is frozen data equal to their released output, and no other Lean runtime text remains in the compiler but the decoder of core module 2 | `RT-01`..`RT-04` | `build` | | The standard library: language-1.2 source beside the compiler whose members are certified production roots, each validated against its oracle by a seeded differential of its evaluator and rustc realizations; bytes and text over `Bytes`, an output buffer of a given capacity written in order; decimal and hexadecimal; the byte order and stable sorts over it; canonical JSON reading and writing; maps and sets over byte keys; SHA-256 against FIPS 180-4, the NIST CAVP vectors, and the `sha2` crate; and the `std-models` and `std-reasoning` source packages, generic over types, whose laws are kernel-checked theorems and whose application is the `helpdesk` example | `SL-01`, `SL-02`, `SL-03`, `SL-04`, `SL-05`, `SL-09`, `SL-10`, `SL-11`, `SL-13`, `SL-14` | `build` | -| The bootstrap project: the compiler's own components as language-1.2 source compiled by LexLean's production pipeline to certified Rust packages, the exact axiom-output parser and its closed Lean-name check, the primitive scanner of §12.2, the preservation lexer and token audit, the target calculus's checker, the Rust crate validator, the Rust printer, the runtime syntax validator, the failure typing and the types of the Rust lowering, its last-use moves, its literal values and its terms, the package renderer, the GNAF request validation, and the LaTeX of a tooling module, each held to the Rust it replaces (the stage-0 oracle) by the committed vectors and a seeded differential of its evaluator and rustc realizations, with planted defects detected and the production export committed | `BS-01`..`BS-20` | `build` | +| The bootstrap project: the compiler's own components as language-1.2 source compiled by LexLean's production pipeline to certified Rust packages, the exact axiom-output parser and its closed Lean-name check, the primitive scanner of §12.2, the preservation lexer and token audit, the target calculus's checker, the Rust crate validator, the Rust printer, the runtime syntax validator, the failure typing and the types of the Rust lowering, its last-use moves, its literal values and its terms, the package renderer, the GNAF request validation, the LaTeX of a tooling module, and the canonical text of the lock file, each held to the Rust it replaces (the stage-0 oracle) by the committed vectors and a seeded differential of its evaluator and rustc realizations, with planted defects detected and the production export committed | `BS-01`..`BS-31` | `build` | | Source packages: a language-1.2 project imports the modules of a locked, content-addressed package of its workspace: `[[source_package]]` and `lexlean-workspace.toml`, the pins in `lexlean.lock` recomputed by every command, imports closed at link, no re-export of a package's production roots, and the package's modules replayed by the importer's `verify` with their origin in the records | `PK-01`..`PK-05` | `build` | | The literal `nat-add-zero` example, the Lean-verified feature examples, and the complete negative fixture suite | `EX-01`..`EX-09` | `build` | | Language-1.2 text components: tokenizers and their round-trip laws, with the laws carried as one native core module the generated modules import rather than authored Lean text | `LM-01`, `LM-02`, `LM-03`, `LM-13` | `build` | diff --git a/SPEC.md b/SPEC.md index 93b9b32971..7dd8451675 100644 --- a/SPEC.md +++ b/SPEC.md @@ -8725,6 +8725,21 @@ the public marker and the visibility line, and the trimming of a line) are each pinned Lean the production export (§24.7) certifies the root beside the others and its package is the committed one. +The canonical text of the lock file (§11.2) is the first component of the project manager as +source (`BS-31`, issue 274), the module `LockText`, with two production roots for `rust-std`: + +| Root | Takes | Returns | Oracle | +| --- | --- | --- | --- | +| `LexLeanBoot.LockText.canonicalLock` | a lock | its canonical bytes | `lock::Lock::canonical_bytes` | +| `LexLeanBoot.LockText.tomlString` | a text | its TOML basic string | `config::toml_string` | + +`canonicalLock` writes the five header keys, then one table for each workspace pin, package, and +source package, then the PDF record and its resources; the rows of each kind are sorted with the +stable merge sort of the standard library's `Order`, a package by an order-preserving key of its +identifier and version. `tomlString` escapes the quote and the backslash with a backslash, and each +control below 0x20 and 0x7F as `\u` and four upper-case hex digits. Neither admits `recursion`. +Reading a lock, resolving its packages, and hashing its files stay in the host. + ## 18. Lean backend ### 18.1 Output contract @@ -11646,6 +11661,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `BS-15` | `bootstrap` | The package renderer of SPEC.md §17.16 (the checks `package::lower` makes of a manifest's own fields before it reads the program: the spec, the crate name against the Rust keywords and the reserved crates, the version, the profile, the form and the order of the sources, and the effects against the registry, with `allocation` refused on `rust-core`; the Cargo manifest over the scaffold record; and the provenance in canonical JSON with the digests of the runtime, the Cargo manifest, and the library) is language-1.2 source in the `bootstrap/` project, as two production roots of `RustPackage` that the host composes around the roots of `BS-04` to `BS-14`: `checkManifest`, which for the fields of a manifest and the registered effects returns whether the profile is `rust-std`, or the refusal of `package::lower` to the byte, and `renderPackage`, which for the scaffold record, the manifest's name, version, profile, sources, effects and exports, the program's identity, the compiler-semantics identity, the two runtime texts, and the library returns the `Cargo.toml` and the `provenance.json` of `package::package` to the byte; each is eligible for `rust-std` with exactly its declared effects and has no part of its certificate beyond 3,145,728 bytes; the oracle of `checkManifest` is `package::lower` on the manifest with its program and exports replaced by a pair every later check accepts, which agrees with each committed negative manifest's refusal, and the oracle of `renderPackage` is `package::package` on the 299 committed manifests it accepts and, on 137 hand-built inputs (names, exports, sources and effects that reach the escaper, and scaffold records that differ from the committed one) and 299 seeded mutants, `cargo_toml_of` and the canonical JSON of §21.7 by the recipe `package::package` is held to; on the normative host the lowered programs under the calculus evaluator agree with the oracle on the 318 committed manifests, 182 rule manifests and 2,000 seeded mutants, and on the 241 renders whose library is at most 16,384 bytes; the rendered packages agree with the oracle under the pinned rustc on all 3,190 runs; 21 planted defects in the source are each detected; and the certified packages the production export publishes for the project are the committed ones; the checks of the program, the exports and the crate, and the bytes of the library, which are the rows `BS-04` to `BS-14`, are outside the claim. | §17.16, §17.23 | | `BS-16` | `bootstrap` | The GNAF request validation of SPEC.md §17.15 (`gnaf::validate`, with `universe_size`) is language-1.2 source in the `bootstrap/` project: `validateRequest` of `GnafValidate` is a production root eligible for `rust-std` with exactly its declared effects, over the projection of a request that validation reads (the length of the domain, the machine, the carrier's kind with each plan's preparations and the thresholds, the completeness evidence, the objective, the claim's class, and the scope) as first-order data, and returns the first violated rule in the model's order as the oracle's `serde_json` bytes, or nothing; on every host, its rendered `rust-std` package under the pinned rustc agrees with the Rust oracle `gnaf::validate` on the acceptance and on the rejection, to the byte, on the committed requests of `compiler/gnaf/`, the requests the committed certificate fixtures name, hand-built requests that reach each rejection, and seeded mutants of the committed requests; on the normative host, the root's lowered program under the calculus evaluator agrees with the oracle on the same corpus, each planted defect in the source is detected, and the certified package the production export publishes for the project is the committed one; loading a request (`gnaf::load`), the universe identity, the answer, and certification are outside the claim. | §17.15, §17.23 | | `BS-20` | `bootstrap` | The canonical LaTeX of a tooling module of SPEC.md §17.20 (`backend::tooling::render_latex`: the fixed document frame and, for each declaration in order, its title, its kind, and the lines the Lean printer of the same file spells for its types, signatures, and terms, every line escaped by `tex_escape`) is language-1.2 source in the `bootstrap/` project: `renderToolingLatex` of `ToolingLatex`, over the tooling module as first-order data with each list carried as a chain of its own `Nil` and `Cons` constructors and with the typings the checker infers as an argument, writing through the standard library's `Buffer` with an explicit capacity, is a production root eligible for `rust-std` with exactly its declared effects; its rendered `rust-std` package under the pinned rustc and its lowered program under the calculus evaluator agree with the Rust oracle on the text, to the byte, and on the refusal of a write past the capacity, on the committed tooling modules (whose committed `.tex` is equal to the text), on hand-built modules that reach every declaration, type, signature, and term form and every byte class of the escaper, and on seeded mutants, every planted defect is detected, and the certified package the production export publishes for the project is the committed one; the checker, the decoder of the module, and the source map of the emitted pieces stay in the host. | §17.20, §17.23 | +| `BS-31` | `bootstrap` | The canonical text of the lock file of SPEC.md §11.2 (`lock::Lock::canonical_bytes`: the header keys in their fixed order with the lock spec of the language and the pinned Lean toolchain, the workspace pins sorted by path, the packages sorted by identifier and version, the source packages sorted by identifier, and the PDF record with its resources sorted by path, each digest in lower-case hex; and `config::toml_string`: the TOML basic string of a text, with the quote, the backslash, and every control escaped) is language-1.2 source in the `bootstrap/` project, as two production roots of `LockText`: `canonicalLock` and `tomlString`, each eligible for `rust-std` with exactly its declared effects, `allocation` and `overflow`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator, agree with the oracle to the byte on hand-built locks and texts, which reach every table, both lock specs, every order of rows the sort decides, and every class of escape, on every committed `lexlean.lock` that parses and every text in them, and on seeded locks and texts; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; reading a lock, resolving its packages, and hashing its files are outside the claim. | §11.2, §17.23 | | `PK-01` | `packages` | A language-1.2 project that declares a source package by its identifier, version, kind `path`, and the member directory a `lexlean-workspace.toml` lists locks it by the tree digest of its manifest and source files, its manifest digest, its version, its module prefix, and its own packages, and the configuration and the lock read back to the bytes written; a project without a source package keeps its bytes, and a package of another kind, a source package in another language, a changed byte or version (LLC0105), an undeclared package (LLC0106), a module prefix claimed twice (LLC0107), a project or a package outside the workspace (LLC0108), a path that escapes it, and a symlink (LLS8001) are each refused with the named code. | §10.5, §11.1, §25.1 | | `PK-02` | `packages` | A module of a project imports only modules of its own project and modules of the packages the project declares, and a module of a package only modules of itself and of the packages its own manifest declares: a package module is a module of the importing project under its own module prefix, a module of a package the project does not declare fails with LLR3009, and an import cycle through a package fails with LLR3003. | §10.5, §15.1 | | `PK-03` | `packages` | An importing project builds and verifies under the pinned Lean offline, and its package modules are generated, elaborated, replayed with `leanchecker`, and audited for their exact axioms under the package's module prefix with the package as their origin in the records; the source ID of the project changes with the pins, and no file of the package is written by `fmt`, `build`, or `verify`. | §10.5, §21.3, §22 | @@ -11662,7 +11678,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `LM-09` | `language-models` | No prompt is code: no member of the closed language maps `string` or `bytes` to a function, a term, or source — every operation of the primitive registry that takes a `string` or `bytes` operand is classified by the audit with a data result, the registry's schema enumeration and the production registry's primitive rows equal one another and equal that classified set, and the text declarations of `lexlean/semantic-module/2` state no `string`-typed member, so a prompt reaches a model only as the tokens `encodeText` makes of it; a planted operation or text member of that shape is caught by the audit with its name. | §17.12 | | `LM-13` | `language-models` | The text laws a tokenizer elaborates through are LexLean source and not authored text: the module that states them is one language-1.2 native core module of the embedded `language/text-1.2` project, the project holds no file of Lean source, no independently authored Lean file anywhere in the release tree declares the `LexLeanText` namespace or lies under its module root, and the one-time migration input is absent; the registry lists only that module, the declarations and their exact axiom policies are read from its native data, which the compiler embeds and hashes into the language-1.2 semantics, and a module that declares a text component imports the generated module rather than splicing any Lean text. | §17.10, §17.12 | -**Total required capability IDs:** 478. +**Total required capability IDs:** 479. No row may be downgraded to `some-true` or `open`. Upstream Lean facts are ledger/authority rows, not substitutions for these build behaviors. diff --git a/VERIFICATION.md b/VERIFICATION.md index 0992f2e61e..4828cb4f8c 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -10999,6 +10999,51 @@ writes them); `cargo clippy -p repo-conformance -p xtask --all-targets --all-features -D warnings`, `validate-model` (461 ids), `validate-spec-links` (461 rows), `check-test-inventory`, and the five `bdd` meta-gate tests pass. +### the canonical text of the lock file is source (BS-31) + +`BS-31` holds the two production roots of `LexLeanBoot.LockText` +(`bootstrap/src/LockText.lex.tex`) to the lock writer: `tomlString` to +`config::toml_string`, the TOML basic string of a text with the quote, the +backslash, each control below 0x20, and 0x7F escaped, the controls as `\u` and +four upper-case hex digits; and `canonicalLock` to `lock::Lock::canonical_bytes`, +the five header keys with the lock spec of the language and the pinned Lean +toolchain, then the workspace pins sorted by path, the packages sorted by +identifier and version, the source packages sorted by identifier, and the PDF +record with its resources sorted by path, each digest in lower-case hex. The rows +are sorted with the stable merge sort of the standard library's `Order`; a +package's key is its identifier and version, each with its NUL bytes escaped and +a two-byte end, so that the byte order of the key is the order of the pair. Each +root admits exactly `allocation` and `overflow`, and neither admits +`recursion`. The oracle is the existing public code of `lock.rs` and +`config.rs`; no Rust outside the case changes. The case holds the roots to the +oracle on hand-built locks that reach every table, both lock specs, a path and +an identifier that are prefixes of others, two versions of one package, an +identifier with a NUL, and escapes in every table; on texts that reach every +class of escape and two- and four-byte UTF-8; on every committed `lexlean.lock` +that parses and every text in them; and on seeded locks and texts. Each planted +defect names the one vector that catches it, and the case asserts that the site +of each plant occurs once. The row's statement carries no counts. + +Measured with the compiler binary of this tree, on a copy of the project whose +only entrypoint is `LockText`: `lexlean check`, `lexlean build`, and `lexlean +verify` pass, and the eligibility report gives each root exactly `allocation` +and `overflow`. The register agrees with the §31 table on 479 IDs, by the same +parse `validate-spec-links` makes. + +The case was first compiled and run on the normative host over +`release/v0.4` at `4318b17b8` (`cargo test -p repo-conformance --test +conformance -- conformance_bs_31`, 187 s). Its corpus is 28 named vectors (14 +texts, 14 locks), the 328 of the 330 committed locks that parse, each of which +is already its own canonical text, the 93 texts in them, and 200 and 1,000 +seeded runs of each root. The evaluator agrees with the oracle on 307 texts and +542 locks, the rendered packages under the pinned rustc on 2,449 runs, and each +of the 18 planted defects is detected by its own vector. The first runs found no +fault of the writer: Lean asked for exactly the axioms the module now declares, +and the case first listed the roots out of their source order. The case then +stops at the stack-bound step, `bootstrap/toml_string is no package of the +committed exports`, as each bootstrap member did before its regeneration, which +produces the two packages. + ## The `bdd` recipe as the parts of one run (Issue #131) With UOR Atlas verified as the parts of one run, the `rest` leg became the diff --git a/crates/conformance/src/cases/bootstrap.rs b/crates/conformance/src/cases/bootstrap.rs index 49c5bbf14c..51d4c3bced 100644 --- a/crates/conformance/src/cases/bootstrap.rs +++ b/crates/conformance/src/cases/bootstrap.rs @@ -22,6 +22,7 @@ use crate::rust_packages; use crate::support::{self, P}; mod gnaf_validate; +mod lock_text; mod runtime_validate; mod rust_assemble; mod rust_bodies; @@ -2457,6 +2458,7 @@ fn case(id: &str) { "BS-16" => gnaf_validate::case(), // §17.23, §17.20: the canonical LaTeX of a tooling module. "BS-20" => tooling_latex::case(), + "BS-31" => lock_text::case(), other => panic!("no bootstrap case is wired for {other}"), } } diff --git a/crates/conformance/src/cases/bootstrap/lock_text.rs b/crates/conformance/src/cases/bootstrap/lock_text.rs new file mode 100644 index 0000000000..4f7554cf33 --- /dev/null +++ b/crates/conformance/src/cases/bootstrap/lock_text.rs @@ -0,0 +1,921 @@ +//! `BS-31` (SPEC.md §11.2, §17.23): the canonical text of the lock file as +//! language-1.2 source, `LexLeanBoot.LockText`, held to the byte to +//! `lexlean::lock::Lock::canonical_bytes` and `lexlean::config::toml_string`. +//! +//! `canonicalLock` writes a lock as `lexlean lock` writes it: the header keys +//! in their fixed order, the workspace pins sorted by path, the packages +//! sorted by identifier and version, the source packages sorted by +//! identifier, and the PDF record with its resources sorted by path; +//! `tomlString` is the TOML basic string of a text, with the quote, the +//! backslash, and the controls escaped. Every committed `lexlean.lock` that +//! parses is a run. +//! +//! Each planted defect names the one vector that catches it. + +use std::collections::{BTreeMap, BTreeSet}; + +use lexlean::calculus::Value; +use lexlean::config::toml_string; +use lexlean::lock::{parse_lock, Lock, LockPackage, LockPdf, LockSourcePackage}; +use lexlean::Sha256Digest; +use serde_json::Value as Json2; + +use super::rust_validate::{eligibility_of, rustc_differential}; +use super::{bytes, list, option, pair, text, texts, Run, Seeded}; +use crate::production_export as harness; +use crate::support::{self, repo_root}; + +const MODULE: &str = "LexLeanBoot.LockText"; +const ROOTS: [(&str, &[&str]); 2] = [ + ("tomlString", &["allocation", "overflow"]), + ("canonicalLock", &["allocation", "overflow"]), +]; + +/// The most a part of a certificate of a root may be, as the row states. +const CERTIFICATE_BUDGET: u64 = 3_145_728; +/// Seeded runs of each root under the evaluator, and under rustc. +const EVALUATOR_SEEDED: usize = 200; +const RUSTC_SEEDED: usize = 1_000; + +// ------------------------------------------------------------- the encoders + +fn digest(value: &Sha256Digest) -> Value { + bytes(&value.0) +} + +fn pins(rows: &[(String, Sha256Digest)]) -> Value { + list( + rows.iter() + .map(|(path, sha256)| pair(text(path), digest(sha256))) + .collect(), + ) +} + +fn enc_package(package: &LockPackage) -> Value { + Value::Adt { + constructor: 0, + fields: vec![ + text(&package.id), + text(&package.version), + text(&package.kind), + text(&package.source), + text(&package.revision), + digest(&package.tree_sha256), + digest(&package.manifest_sha256), + texts(&package.imports), + ], + } +} + +fn enc_source(package: &LockSourcePackage) -> Value { + Value::Adt { + constructor: 0, + fields: vec![ + text(&package.id), + text(&package.version), + text(&package.kind), + text(&package.source), + text(&package.module_prefix), + digest(&package.tree_sha256), + digest(&package.manifest_sha256), + texts(&package.imports), + ], + } +} + +fn enc_pdf(pdf: &LockPdf) -> Value { + Value::Adt { + constructor: 0, + fields: vec![ + text(&pdf.program), + digest(&pdf.program_sha256), + texts(&pdf.version_argv), + digest(&pdf.version_stdout_sha256), + texts(&pdf.compile_argv), + text(&pdf.output), + pins(&pdf.resources), + ], + } +} + +fn enc(lock: &Lock) -> Value { + Value::Adt { + constructor: 0, + fields: vec![ + text(&lock.language), + digest(&lock.compiler_semantics), + digest(&lock.project_config_sha256), + pins(&lock.workspace_files), + list(lock.packages.iter().map(enc_package).collect()), + list(lock.source_packages.iter().map(enc_source).collect()), + option(lock.pdf.as_ref().map(enc_pdf)), + ], + } +} + +fn lock_run(lock: &Lock) -> Run { + ( + vec![enc(lock)], + serde_json::to_value(bytes(&lock.canonical_bytes())).expect("a value is JSON"), + ) +} + +fn string_run(value: &str) -> Run { + ( + vec![text(value)], + serde_json::to_value(text(&toml_string(value))).expect("a value is JSON"), + ) +} + +// ------------------------------------------------------------------ corpora + +fn locks_under(dir: &std::path::Path, out: &mut Vec) { + let Ok(entries) = std::fs::read_dir(dir) else { + return; + }; + let mut entries: Vec<_> = entries.flatten().collect(); + entries.sort_by_key(std::fs::DirEntry::file_name); + for entry in entries { + let name = entry.file_name().to_string_lossy().into_owned(); + let path = entry.path(); + if path.is_dir() { + if !matches!(name.as_str(), ".git" | "target" | ".lexlean") { + locks_under(&path, out); + } + } else if name == "lexlean.lock" { + out.push(path); + } + } +} + +/// Every committed lock that parses, how many committed locks there are, +/// and how many of those that parse are their own canonical text. +fn committed() -> (Vec, usize, usize) { + let root = repo_root(); + let mut paths = Vec::new(); + locks_under(root.as_std_path(), &mut paths); + let found = paths.len(); + let mut canonical = 0usize; + let locks = paths + .iter() + .filter_map(|path| { + let bytes = std::fs::read(path).expect("a committed lock"); + let lock = parse_lock(&path.to_string_lossy(), &bytes).ok()?; + if lock.canonical_bytes() == bytes { + canonical += 1; + } + Some(lock) + }) + .collect(); + (locks, found, canonical) +} + +/// Every text of the committed locks, once. +fn texts_of(locks: &[Lock]) -> BTreeSet { + let mut out = BTreeSet::new(); + for lock in locks { + out.insert(lock.language.clone()); + for (path, _) in &lock.workspace_files { + out.insert(path.clone()); + } + for package in &lock.packages { + out.extend([ + package.id.clone(), + package.version.clone(), + package.kind.clone(), + package.source.clone(), + package.revision.clone(), + ]); + out.extend(package.imports.iter().cloned()); + } + for package in &lock.source_packages { + out.extend([ + package.id.clone(), + package.version.clone(), + package.kind.clone(), + package.source.clone(), + package.module_prefix.clone(), + ]); + out.extend(package.imports.iter().cloned()); + } + if let Some(pdf) = &lock.pdf { + out.insert(pdf.program.clone()); + out.insert(pdf.output.clone()); + out.extend(pdf.version_argv.iter().cloned()); + out.extend(pdf.compile_argv.iter().cloned()); + for (path, _) in &pdf.resources { + out.insert(path.clone()); + } + } + } + out +} + +// ------------------------------------------------------------------ vectors + +fn sha(byte: u8) -> Sha256Digest { + let mut out = [0u8; 32]; + for (index, slot) in out.iter_mut().enumerate() { + *slot = byte.wrapping_add(u8::try_from(index).expect("a byte")); + } + Sha256Digest(out) +} + +fn strings(items: &[&str]) -> Vec { + items.iter().map(|item| (*item).to_owned()).collect() +} + +fn empty(language: &str) -> Lock { + Lock { + language: language.to_owned(), + compiler_semantics: sha(0xa0), + project_config_sha256: sha(0x0f), + workspace_files: Vec::new(), + packages: Vec::new(), + source_packages: Vec::new(), + pdf: None, + } +} + +fn package(id: &str, version: &str, imports: &[&str]) -> LockPackage { + LockPackage { + id: id.to_owned(), + version: version.to_owned(), + kind: "lexicon".to_owned(), + source: format!("path:../{id}"), + revision: format!("r-{id}-{version}"), + tree_sha256: sha(0x10), + manifest_sha256: sha(0xf0), + imports: strings(imports), + } +} + +fn source(id: &str, prefix: &str) -> LockSourcePackage { + LockSourcePackage { + id: id.to_owned(), + version: "1.2.0".to_owned(), + kind: "source".to_owned(), + source: format!("path:../{id}"), + module_prefix: prefix.to_owned(), + tree_sha256: sha(0x20), + manifest_sha256: sha(0xe0), + imports: strings(&["lexlean.std.nat"]), + } +} + +fn pdf(resources: &[&str]) -> LockPdf { + LockPdf { + program: "lualatex".to_owned(), + program_sha256: sha(0x30), + version_argv: strings(&["--version"]), + version_stdout_sha256: sha(0x40), + compile_argv: strings(&["-interaction=nonstopmode", "-halt-on-error", "main.tex"]), + output: "main.pdf".to_owned(), + resources: resources + .iter() + .enumerate() + .map(|(index, path)| { + ( + (*path).to_owned(), + sha(u8::try_from(index).expect("a byte")), + ) + }) + .collect(), + } +} + +fn files(paths: &[&str]) -> Vec<(String, Sha256Digest)> { + paths + .iter() + .enumerate() + .map(|(index, path)| { + ( + (*path).to_owned(), + sha(0x50 + u8::try_from(index).expect("a byte")), + ) + }) + .collect() +} + +enum Subject { + Lock(Box), + Text(String), +} + +struct Vector { + label: String, + subject: Subject, +} + +impl Vector { + fn root(&self) -> usize { + match self.subject { + Subject::Text(_) => 0, + Subject::Lock(_) => 1, + } + } + + fn run(&self) -> Run { + match &self.subject { + Subject::Lock(lock) => lock_run(lock), + Subject::Text(value) => string_run(value), + } + } +} + +#[allow(clippy::too_many_lines)] +fn named() -> Vec { + let mut out: Vec = Vec::new(); + let mut lock = |label: &str, value: Lock| { + out.push(Vector { + label: label.to_owned(), + subject: Subject::Lock(Box::new(value)), + }); + }; + lock("an empty language-1.1 lock", empty("1.1")); + lock("an empty language-1.2 lock", empty("1.2")); + lock( + "one workspace file", + Lock { + workspace_files: files(&["src/Main.lex.tex"]), + ..empty("1.2") + }, + ); + lock( + "workspace files out of order", + Lock { + workspace_files: files(&["src/b.lex.tex", "lexlean.toml", "src/a.lex.tex"]), + ..empty("1.2") + }, + ); + lock( + "a path that is a prefix of another", + Lock { + workspace_files: files(&["a/b", "a.b", "a"]), + ..empty("1.1") + }, + ); + lock( + "every field of a package", + Lock { + packages: vec![package("lexlean.std.nat", "1.2.0", &[])], + ..empty("1.2") + }, + ); + lock( + "two versions of a package", + Lock { + packages: vec![package("p", "2.0.0", &[]), package("p", "1.0.0", &[])], + ..empty("1.2") + }, + ); + lock( + "an identifier that is a prefix of another", + Lock { + packages: vec![package("a.b", "1", &[]), package("a", "2", &[])], + ..empty("1.2") + }, + ); + lock( + "an identifier with a NUL", + Lock { + packages: vec![package("a\0", "1", &[]), package("a", "9", &[])], + ..empty("1.2") + }, + ); + lock( + "imports in their order", + Lock { + packages: vec![package("q", "1.0.0", &["z", "a", "m"])], + ..empty("1.2") + }, + ); + lock( + "source packages out of order", + Lock { + source_packages: vec![source("zeta", "Zeta"), source("alpha", "Alpha")], + ..empty("1.2") + }, + ); + lock( + "a pdf record", + Lock { + workspace_files: files(&["main.tex"]), + pdf: Some(pdf(&["fonts/b.otf", "fonts/a.otf"])), + ..empty("1.2") + }, + ); + lock( + "a pdf with no resources", + Lock { + pdf: Some(pdf(&[])), + ..empty("1.1") + }, + ); + lock( + "escapes in every table", + Lock { + workspace_files: files(&["dir with \"quote\"/a\\b"]), + packages: vec![package("p", "1\t0", &["tab\there", "line\nnext"])], + source_packages: vec![source("s", "Pre\u{7f}fix")], + pdf: Some(pdf(&["caf\u{e9}.png"])), + ..empty("1.2") + }, + ); + let mut add = |label: &str, value: &str| { + out.push(Vector { + label: label.to_owned(), + subject: Subject::Text(value.to_owned()), + }); + }; + add("the empty text", ""); + add("plain text", "lexlean/lock/2"); + add("a quote", "say \"hi\""); + add("a backslash", "a\\b"); + add("a newline", "one\ntwo"); + add("a tab", "a\tb"); + add("a NUL", "\0"); + add("a vertical tab", "\u{b}"); + add("the unit separator", "\u{1f}"); + add("a space", " "); + add("delete", "\u{7f}"); + add("a tilde", "~"); + add("two-byte text", "caf\u{e9}"); + add("four-byte text", "\u{1f600}"); + out +} + +// ------------------------------------------------------------------- seeded + +const PIECES: &[&str] = &[ + "a", + "b", + "z", + "A", + "0", + "9", + ".", + "/", + "-", + "_", + " ", + "\"", + "\\", + "\n", + "\t", + "\r", + "\0", + "\u{1}", + "\u{1b}", + "\u{1f}", + "\u{7f}", + "~", + "\u{e9}", + "\u{3b1}", + "\u{1f600}", +]; +const IDS: &[&str] = &["a", "a.b", "a-b", "a/b", "b", "lexlean.std.nat", "", "a\0"]; +const VERSIONS: &[&str] = &["1.0.0", "1.0", "1.2.0", "2.0.0", "10.0.0", ""]; + +fn drawn_text(seeded: &mut Seeded) -> String { + let count = seeded.below(9); + (0..count).map(|_| *seeded.pick(PIECES)).collect() +} + +fn drawn_texts(seeded: &mut Seeded) -> Vec { + let count = seeded.below(4); + (0..count).map(|_| drawn_text(seeded)).collect() +} + +fn drawn_sha(seeded: &mut Seeded) -> Sha256Digest { + let mut out = [0u8; 32]; + for slot in &mut out { + *slot = u8::try_from(seeded.below(256)).expect("a byte"); + } + Sha256Digest(out) +} + +fn drawn_pins(seeded: &mut Seeded) -> Vec<(String, Sha256Digest)> { + let count = seeded.below(5); + (0..count) + .map(|_| { + let path = if seeded.chance(50) { + (*seeded.pick(IDS)).to_owned() + } else { + drawn_text(seeded) + }; + (path, drawn_sha(seeded)) + }) + .collect() +} + +fn drawn_lock(seeded: &mut Seeded) -> Lock { + let language = (*seeded.pick(&["1.0", "1.1", "1.2", "1.2", ""])).to_owned(); + let compiler_semantics = drawn_sha(seeded); + let project_config_sha256 = drawn_sha(seeded); + let workspace_files = drawn_pins(seeded); + let packages = (0..seeded.below(5)) + .map(|_| LockPackage { + id: (*seeded.pick(IDS)).to_owned(), + version: (*seeded.pick(VERSIONS)).to_owned(), + kind: drawn_text(seeded), + source: drawn_text(seeded), + revision: drawn_text(seeded), + tree_sha256: drawn_sha(seeded), + manifest_sha256: drawn_sha(seeded), + imports: drawn_texts(seeded), + }) + .collect(); + let source_packages = (0..seeded.below(4)) + .map(|_| LockSourcePackage { + id: (*seeded.pick(IDS)).to_owned(), + version: (*seeded.pick(VERSIONS)).to_owned(), + kind: drawn_text(seeded), + source: drawn_text(seeded), + module_prefix: drawn_text(seeded), + tree_sha256: drawn_sha(seeded), + manifest_sha256: drawn_sha(seeded), + imports: drawn_texts(seeded), + }) + .collect(); + let pdf = if seeded.chance(30) { + Some(LockPdf { + program: drawn_text(seeded), + program_sha256: drawn_sha(seeded), + version_argv: drawn_texts(seeded), + version_stdout_sha256: drawn_sha(seeded), + compile_argv: drawn_texts(seeded), + output: drawn_text(seeded), + resources: drawn_pins(seeded), + }) + } else { + None + }; + Lock { + language, + compiler_semantics, + project_config_sha256, + workspace_files, + packages, + source_packages, + pdf, + } +} + +fn seeded_runs(count: usize, seed: u64) -> [Vec; 2] { + let mut seeded = Seeded(seed); + let mut out: [Vec; 2] = [Vec::new(), Vec::new()]; + for _ in 0..count { + out[1].push(lock_run(&drawn_lock(&mut seeded))); + out[0].push(string_run(&drawn_text(&mut seeded))); + } + out +} + +// ------------------------------------------------------------------- plants + +struct Plant { + label: &'static str, + root: usize, + site: &'static str, + replacement: &'static str, + vector: &'static str, +} + +const PLANTS: &[Plant] = &[ + Plant { + label: "the quote is not escaped", + root: 0, + site: "(if (value =? 34) then 0x5c22 else", + replacement: "(if (value =? 34) then 0x22 else", + vector: "a quote", + }, + Plant { + label: "the backslash is not escaped", + root: 0, + site: "(if (value =? 92) then 0x5c5c else", + replacement: "(if (value =? 92) then 0x5c else", + vector: "a backslash", + }, + Plant { + label: "the controls end before the newline", + root: 0, + site: "(if (value (cons (tomlString item) acc)) (nil Bytes) values : (List Bytes)))", + replacement: "(prim list_fold (fun (acc : (List Bytes)) (item : Bytes) => (cons (tomlString item) acc)) (nil Bytes) values : (List Bytes))", + vector: "imports in their order", + }, + Plant { + label: "source packages are not sorted", + root: 1, + site: "(sourcesSorted (project given sourcePackages))", + replacement: "(project given sourcePackages)", + vector: "source packages out of order", + }, + Plant { + label: "the array separator has no space", + root: 1, + site: "(lit \", \")", + replacement: "(lit \",\")", + vector: "a pdf record", + }, + Plant { + label: "the pdf record is dropped", + root: 1, + site: "| Option.some entry => (pdfText entry)", + replacement: "| Option.some entry => 0x", + vector: "a pdf with no resources", + }, +]; + +fn plants(vectors: &[Vector]) { + let mut missed = Vec::new(); + for plant in PLANTS { + let vector = vectors + .iter() + .find(|vector| vector.label == plant.vector) + .unwrap_or_else(|| panic!("{}: no vector `{}`", plant.label, plant.vector)); + assert_eq!( + vector.root(), + plant.root, + "{}: the vector is a run of the root planted", + plant.label + ); + let planted = support::P::bootstrap(); + let source = planted.read_raw("src/LockText.lex.tex"); + assert_eq!( + source.matches(plant.site).count(), + 1, + "{}: the plant site occurs once", + plant.label + ); + planted.write( + "src/LockText.lex.tex", + &source.replacen(plant.site, plant.replacement, 1), + ); + let checked = support::checked_project(&planted); + let low = super::lower(&checked, &planted, MODULE, ROOTS[plant.root].0); + match super::evaluate(&low, &[vector.run()], 1).first() { + Some(first) => eprintln!( + "BS-31: plant detected: {}: {}", + plant.label, + first.chars().take(160).collect::() + ), + None => missed.push(plant.label), + } + } + assert!( + missed.is_empty(), + "planted defects their own vector does not detect: {missed:?}" + ); +} + +fn export(lowered: &BTreeMap<&str, super::Lowered>) { + let exported = harness::exported("bootstrap"); + let bundle = exported.bundle(); + let mut realized = 0usize; + for exported_root in &exported.output.result.roots { + let Some((member, low)) = exported_root + .root + .strip_prefix(&format!("{MODULE}.")) + .and_then(|member| lowered.get(member).map(|low| (member, low))) + else { + continue; + }; + let largest = exported_root + .outputs + .iter() + .flat_map(|output| &output.certification.certificates) + .map(|certificate| certificate.file.byte_length) + .max() + .expect("a certificate"); + eprintln!( + "BS-31: {}: largest certificate part {largest} bytes", + exported_root.root + ); + assert!( + largest <= CERTIFICATE_BUDGET, + "{}: a certificate part of {largest} bytes is beyond {CERTIFICATE_BUDGET}", + exported_root.root + ); + for output in &exported_root.outputs { + let package: Json2 = serde_json::from_slice( + &std::fs::read( + bundle + .join(&output.package.directory) + .join("package.json") + .as_std_path(), + ) + .expect("package.json"), + ) + .expect("package JSON"); + assert_eq!( + package["program"], + serde_json::to_value(&low.program).expect("a program is JSON"), + "{member}: the exported package realizes the program the differential ran" + ); + realized += 1; + } + } + assert_eq!(realized, ROOTS.len(), "one certified package per root"); + let packages = harness::tree(&bundle.join("packages")); + let committed_packages = harness::tree(&harness::fixture_dir("bootstrap").join("packages")); + assert_eq!( + packages.keys().collect::>(), + committed_packages.keys().collect::>(), + "the exported package files are the committed ones" + ); + for (relative, content) in &packages { + assert!( + committed_packages.get(relative) == Some(content), + "packages/{relative} differs from the committed package" + ); + } +} + +#[allow(clippy::too_many_lines)] +pub(super) fn case() { + let started = std::time::Instant::now(); + let project = support::P::bootstrap(); + let checked_units = project.check_ok(); + assert!( + checked_units.units.contains_key("LockText"), + "LockText is a linked module of the project" + ); + eligibility_of(&project, "LockText", MODULE, &ROOTS); + + let vectors = named(); + let labels: BTreeSet<&str> = vectors.iter().map(|vector| vector.label.as_str()).collect(); + assert_eq!(labels.len(), vectors.len(), "each vector has its own label"); + let mut runs: [Vec; 2] = [Vec::new(), Vec::new()]; + for vector in &vectors { + runs[vector.root()].push(vector.run()); + } + + // Every committed lock that parses, and every text in them. + let (locks, found, canonical) = committed(); + assert!( + locks.iter().any(|lock| lock.pdf.is_some()) + && locks.iter().any(|lock| !lock.source_packages.is_empty()) + && locks.iter().any(|lock| !lock.packages.is_empty()), + "the committed locks reach every table" + ); + let words = texts_of(&locks); + let corpus: [Vec; 2] = [ + words.iter().map(|word| string_run(word)).collect(), + locks.iter().map(lock_run).collect(), + ]; + let normative = support::normative_host(); + let (evaluator_seeded, rustc_seeded) = if normative { + ( + seeded_runs(EVALUATOR_SEEDED, 0x0B55_0031), + seeded_runs(RUSTC_SEEDED, 0x0B55_1031), + ) + } else { + ([Vec::new(), Vec::new()], [Vec::new(), Vec::new()]) + }; + eprintln!( + "BS-31: {} vectors ({} texts, {} locks), {} of {} committed locks parse ({} are their canonical text), {} texts in them, {} and {} seeded runs of each root ({:?})", + vectors.len(), + runs[0].len(), + runs[1].len(), + locks.len(), + found, + canonical, + words.len(), + EVALUATOR_SEEDED, + RUSTC_SEEDED, + started.elapsed() + ); + + let checked = support::checked_project(&project); + let lowered: BTreeMap<&str, super::Lowered> = ROOTS + .iter() + .map(|(root, _)| (*root, super::lower(&checked, &project, MODULE, root))) + .collect(); + if normative { + for (index, (root, _)) in ROOTS.iter().enumerate() { + let mut all_runs: Vec = runs[index].clone(); + all_runs.extend(corpus[index].iter().cloned()); + all_runs.extend(evaluator_seeded[index].iter().cloned()); + let disagreements = super::evaluate(&lowered[root], &all_runs, 5); + assert!( + disagreements.is_empty(), + "{root} and the Rust oracle disagree: {disagreements:?}" + ); + eprintln!( + "BS-31: {root}: the evaluator agrees on {} runs ({:?})", + all_runs.len(), + started.elapsed() + ); + } + plants(&vectors); + } else { + eprintln!("BS-31: platform-bound host: the evaluator, the seeded runs, and the planted defects run on the normative host"); + } + + let mut compiled: [Vec; 2] = [Vec::new(), Vec::new()]; + for index in 0..2 { + compiled[index].extend(runs[index].iter().cloned()); + compiled[index].extend(corpus[index].iter().cloned()); + compiled[index].extend(rustc_seeded[index].iter().cloned()); + } + let total = rustc_differential( + "BS-31", + &[ + (ROOTS[0].0, &lowered[ROOTS[0].0], compiled[0].as_slice()), + (ROOTS[1].0, &lowered[ROOTS[1].0], compiled[1].as_slice()), + ], + "oracle", + ); + eprintln!("BS-31: {total} rustc runs agree ({:?})", started.elapsed()); + + if !support::lean_backed("BS-31") { + return; + } + export(&lowered); + eprintln!("BS-31: passed in {:?}", started.elapsed()); +} diff --git a/crates/conformance/src/cases/repository.rs b/crates/conformance/src/cases/repository.rs index 7df18c8c4a..aaab4a220b 100644 --- a/crates/conformance/src/cases/repository.rs +++ b/crates/conformance/src/cases/repository.rs @@ -873,7 +873,7 @@ pub(crate) fn run(id: &str) { let model = repo_model::Model::load(&root.join("model").into_std_path_buf()) .expect("the model loads"); let table = spec_table(); - assert_eq!(table.len(), 478, "§31 has 478 rows"); + assert_eq!(table.len(), 479, "§31 has 479 rows"); assert_eq!(model.ids.id.len(), table.len(), "register row count"); for ((spec_id, spec_suite, spec_statement), row) in table.iter().zip(model.ids.id.iter()) diff --git a/crates/conformance/tests/conformance.rs b/crates/conformance/tests/conformance.rs index 992ea8a7b3..f40b14575f 100644 --- a/crates/conformance/tests/conformance.rs +++ b/crates/conformance/tests/conformance.rs @@ -2320,6 +2320,11 @@ fn conformance_bs_20() { repo_conformance::cases::run("BS-20"); } +#[test] +fn conformance_bs_31() { + repo_conformance::cases::run("BS-31"); +} + #[test] fn conformance_pk_01() { repo_conformance::cases::run("PK-01"); diff --git a/features/suites/bootstrap.feature b/features/suites/bootstrap.feature index 31570df912..66ebfdc2f9 100644 --- a/features/suites/bootstrap.feature +++ b/features/suites/bootstrap.feature @@ -119,3 +119,10 @@ Feature: bootstrap When the project is checked and built, the lowered program of the root is run by the evaluator on those modules and the mutants, and its rendered rust-std package is run by the pinned rustc on the modules, each with the capacity that fits and capacities that do not Then the root is eligible for rust-std with exactly its declared effects and no run disagrees with the oracle text, to the byte, or with its refusal And every planted defect is detected, and the exported package is byte-identical to its committed package and realizes the lowered program + + @BS-31 @build + Scenario: The canonical text of the lock file of SPEC.md §11.2 (`lock::Lock::canonical_bytes`: the header keys in their fixed order with the lock spec of the language and the pinned Lean toolchain, the workspace pins sorted by path, the packages sorted by identifier and version, the source packages sorted by identifier, and the PDF record with its resources sorted by path, each digest in lower-case hex; and `config::toml_string`: the TOML basic string of a text, with the quote, the backslash, and every control escaped) is language-1.2 source in the `bootstrap/` project, as two production roots of `LockText`: `canonicalLock` and `tomlString`, each eligible for `rust-std` with exactly its declared effects, `allocation` and `overflow`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator, agree with the oracle to the byte on hand-built locks and texts, which reach every table, both lock specs, every order of rows the sort decides, and every class of escape, on every committed `lexlean.lock` that parses and every text in them, and on seeded locks and texts; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; reading a lock, resolving its packages, and hashing its files are outside the claim. + Given the committed `bootstrap` project, hand-built locks and texts, every committed `lexlean.lock` that parses and every text in them, and seeded locks and texts + When the project is checked and built, and the lowered program and the rendered package of each root are run on those locks and texts + Then each root is eligible for rust-std with exactly its declared effects, no certificate part is beyond 3,145,728 bytes, and the two roots equal `Lock::canonical_bytes` and `toml_string` on every run + And every planted defect is detected by its own vector, and the exported packages are byte-identical to the committed packages and realize the programs the differential ran diff --git a/model/ids.toml b/model/ids.toml index 69eb399d8a..07b5844b94 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -2786,6 +2786,12 @@ level = "build" suite = "bootstrap" statement = "The canonical LaTeX of a tooling module of SPEC.md §17.20 (`backend::tooling::render_latex`: the fixed document frame and, for each declaration in order, its title, its kind, and the lines the Lean printer of the same file spells for its types, signatures, and terms, every line escaped by `tex_escape`) is language-1.2 source in the `bootstrap/` project: `renderToolingLatex` of `ToolingLatex`, over the tooling module as first-order data with each list carried as a chain of its own `Nil` and `Cons` constructors and with the typings the checker infers as an argument, writing through the standard library's `Buffer` with an explicit capacity, is a production root eligible for `rust-std` with exactly its declared effects; its rendered `rust-std` package under the pinned rustc and its lowered program under the calculus evaluator agree with the Rust oracle on the text, to the byte, and on the refusal of a write past the capacity, on the committed tooling modules (whose committed `.tex` is equal to the text), on hand-built modules that reach every declaration, type, signature, and term form and every byte class of the escaper, and on seeded mutants, every planted defect is detected, and the certified package the production export publishes for the project is the committed one; the checker, the decoder of the module, and the source map of the emitted pieces stay in the host." +[[id]] +id = "BS-31" +level = "build" +suite = "bootstrap" +statement = "The canonical text of the lock file of SPEC.md §11.2 (`lock::Lock::canonical_bytes`: the header keys in their fixed order with the lock spec of the language and the pinned Lean toolchain, the workspace pins sorted by path, the packages sorted by identifier and version, the source packages sorted by identifier, and the PDF record with its resources sorted by path, each digest in lower-case hex; and `config::toml_string`: the TOML basic string of a text, with the quote, the backslash, and every control escaped) is language-1.2 source in the `bootstrap/` project, as two production roots of `LockText`: `canonicalLock` and `tomlString`, each eligible for `rust-std` with exactly its declared effects, `allocation` and `overflow`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator, agree with the oracle to the byte on hand-built locks and texts, which reach every table, both lock specs, every order of rows the sort decides, and every class of escape, on every committed `lexlean.lock` that parses and every text in them, and on seeded locks and texts; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; reading a lock, resolving its packages, and hashing its files are outside the claim." + [[id]] id = "PK-01" level = "build" diff --git a/xtask/src/spec_links.rs b/xtask/src/spec_links.rs index d3b755a3d4..962afcafd8 100644 --- a/xtask/src/spec_links.rs +++ b/xtask/src/spec_links.rs @@ -61,8 +61,8 @@ fn parse_table(spec: &str) -> Result, Fail> { pub fn validate(root: &Path) -> Result<(), Fail> { let spec = std::fs::read_to_string(root.join("SPEC.md"))?; let rows = parse_table(&spec)?; - if rows.len() != 478 { - return Err(format!("RP-07: the §31 table has {} rows, not 478", rows.len()).into()); + if rows.len() != 479 { + return Err(format!("RP-07: the §31 table has {} rows, not 479", rows.len()).into()); } // The prose total under the table is part of the contract a reader // relies on; a row added without it would leave §31 contradicting itself. From 48a64fe73d1eb1f0d38d88365849baed759035b1 Mon Sep 17 00:00:00 2001 From: humuhumu33 Date: Tue, 10 Nov 2026 01:49:18 +0000 Subject: [PATCH 2/2] BS-31: the canonical text of the lock file, LockText bootstrap/src/LockText.lex.tex: tomlString writes the TOML basic string of a text; canonicalLock writes a lock as lexlean lock does, with its rows sorted by the standard library's stable merge sort. Lean verifies the module and each root is eligible with exactly allocation and overflow. The entrypoint, the lock, the two export roots, and the project README follow. Co-Authored-By: Claude Opus 5.5 --- bootstrap/README.md | 3 + bootstrap/lexlean.lock | 2 +- bootstrap/lexlean.toml | 2 +- bootstrap/src/LockText.lex.tex | 265 +++++++++++++++++++ tests/production-export/bootstrap/roots.json | 16 ++ 5 files changed, 286 insertions(+), 2 deletions(-) create mode 100644 bootstrap/src/LockText.lex.tex diff --git a/bootstrap/README.md b/bootstrap/README.md index a9f234eb1a..46bcfa61c2 100644 --- a/bootstrap/README.md +++ b/bootstrap/README.md @@ -18,3 +18,6 @@ payloads a printer reads); `src/RustPrint.lex.tex` also imports the standard library's `Buffer` (`stdlib/src/Buffer.lex.tex`), which it writes through. `src/GnafValidate.lex.tex` (SPEC.md §17.15, `BS-16`) imports `Buffer` alone and writes the rejection of a GNAF request through it. + +`src/LockText.lex.tex` (SPEC.md §17.23, `BS-31`) imports the standard library's `Numeral`, +`Order`, and `Text`, and writes the canonical lock text of SPEC.md §11.2. diff --git a/bootstrap/lexlean.lock b/bootstrap/lexlean.lock index dec1db451b..3ecbcb30c2 100644 --- a/bootstrap/lexlean.lock +++ b/bootstrap/lexlean.lock @@ -1,7 +1,7 @@ spec = "lexlean/lock/2" language = "1.2" compiler_semantics = "635a25acb886587f8777525e778092e9599d1f2df26da59403ee39e9e299151a" -project_config_sha256 = "b2bd695c7fad3f83d9a41fdabb6f9f5eee0538452d59609e5170eff53d78f14f" +project_config_sha256 = "556ae88888d0da424b6160ea14de260c39a729b7bb26ba45fcf023c7cb24b724" lean_toolchain = "leanprover/lean4:v4.32.1" [[workspace_file]] diff --git a/bootstrap/lexlean.toml b/bootstrap/lexlean.toml index f57986a7e8..d3c093b10b 100644 --- a/bootstrap/lexlean.toml +++ b/bootstrap/lexlean.toml @@ -3,7 +3,7 @@ name = "bootstrap" language = "1.2" module_prefix = "LexLeanBoot" source_roots = ["src"] -entrypoints = ["src/AxiomOutput.lex.tex", "src/CalculusCheck.lex.tex", "src/GnafValidate.lex.tex", "src/PrimitiveScan.lex.tex", "src/RuntimeValidate.lex.tex", "src/RustAssemble.lex.tex", "src/RustAst.lex.tex", "src/RustBodies.lex.tex", "src/RustLoops.lex.tex", "src/RustLower.lex.tex", "src/RustMoves.lex.tex", "src/RustPackage.lex.tex", "src/RustPrint.lex.tex", "src/RustSucceed.lex.tex", "src/RustTerms.lex.tex", "src/RustValidate.lex.tex", "src/TokenAudit.lex.tex", "src/ToolingAst.lex.tex", "src/ToolingLatex.lex.tex"] +entrypoints = ["src/AxiomOutput.lex.tex", "src/CalculusCheck.lex.tex", "src/GnafValidate.lex.tex", "src/LockText.lex.tex", "src/PrimitiveScan.lex.tex", "src/RuntimeValidate.lex.tex", "src/RustAssemble.lex.tex", "src/RustAst.lex.tex", "src/RustBodies.lex.tex", "src/RustLoops.lex.tex", "src/RustLower.lex.tex", "src/RustMoves.lex.tex", "src/RustPackage.lex.tex", "src/RustPrint.lex.tex", "src/RustSucceed.lex.tex", "src/RustTerms.lex.tex", "src/RustValidate.lex.tex", "src/TokenAudit.lex.tex", "src/ToolingAst.lex.tex", "src/ToolingLatex.lex.tex"] build_root = ".lexlean" lockfile = "lexlean.lock" lean_workspace = "." diff --git a/bootstrap/src/LockText.lex.tex b/bootstrap/src/LockText.lex.tex new file mode 100644 index 0000000000..03c55feb0d --- /dev/null +++ b/bootstrap/src/LockText.lex.tex @@ -0,0 +1,265 @@ +\begin{lexlean}{LockText} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Numeral} +\importmodule{LexLeanStd.Order} +\importmodule{LexLeanStd.Text} +\title{Natural number addition} +\begin{semanticmodule} +structure{ + name: LockPackage, + type_parameters: [], + parameters: [], + fields: [ + {name: ident, type: Bytes}, + {name: version, type: Bytes}, + {name: kind, type: Bytes}, + {name: origin, type: Bytes}, + {name: revision, type: Bytes}, + {name: treeSha256, type: Bytes}, + {name: manifestSha256, type: Bytes}, + {name: imports, type: (List Bytes)} + ] +} + +structure{ + name: LockSourcePackage, + type_parameters: [], + parameters: [], + fields: [ + {name: ident, type: Bytes}, + {name: version, type: Bytes}, + {name: kind, type: Bytes}, + {name: origin, type: Bytes}, + {name: modulePrefix, type: Bytes}, + {name: treeSha256, type: Bytes}, + {name: manifestSha256, type: Bytes}, + {name: imports, type: (List Bytes)} + ] +} + +structure{ + name: LockPdf, + type_parameters: [], + parameters: [], + fields: [ + {name: program, type: Bytes}, + {name: programSha256, type: Bytes}, + {name: versionArgv, type: (List Bytes)}, + {name: versionStdoutSha256, type: Bytes}, + {name: compileArgv, type: (List Bytes)}, + {name: output, type: Bytes}, + {name: resources, type: (List (Bytes * Bytes))} + ] +} + +structure{ + name: Lock, + type_parameters: [], + parameters: [], + fields: [ + {name: language, type: Bytes}, + {name: compilerSemantics, type: Bytes}, + {name: projectConfigSha256, type: Bytes}, + {name: workspaceFiles, type: (List (Bytes * Bytes))}, + {name: packages, type: (List LockPackage)}, + {name: sourcePackages, type: (List LockSourcePackage)}, + {name: pdf, type: (Option LockPdf)} + ] +} + +definition{ + name: lit, + parameters: [literal : String], + result: Bytes, + body: (prim utf8_encode literal : Bytes), + executable: true +} + +definition{ + name: cat, + parameters: [left : Bytes, right : Bytes], + result: Bytes, + body: (prim append left right : Bytes), + executable: true +} + +definition{ + name: leanToolchain, + parameters: [], + result: Bytes, + body: (lit "leanprover/lean4:v4.32.1"), + executable: true +} + +definition{ + name: upperHex, + parameters: [value : Nat], + result: Bytes, + body: (LexLeanStd.Numeral::pick 0x30313233343536373839414243444546 value), + executable: true +} + +definition{ + name: escapeByte, + parameters: [value : Nat], + result: Bytes, + body: (if (value =? 34) then 0x5c22 else (if (value =? 92) then 0x5c5c else (if (if (value (ctor Option.some [(Nat * Bytes)] (((first state) + 1), (cat (second state) (escapeByte (prim to_nat byte : Nat))))) + | Option.none => (ctor Option.none [(Nat * Bytes)])), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: tomlString, + parameters: [value : Bytes], + result: Bytes, + body: (cat (cat 0x22 (second (first (prim iterate_until (fun [value] (state : (Nat * Bytes)) => (escapeStep value state)) ((prim length value : Nat) + 1) (0, 0x) : ((Nat * Bytes) * Bool))))) 0x22), + axioms: [Quot.sound, propext], + executable: true, + production: {effects: [allocation, overflow], targets: [rust-std]} +} + +definition{ + name: tomlArray, + parameters: [values : (List Bytes)], + result: Bytes, + body: (cat (cat (lit "[") (LexLeanStd.Text::joinWith (LexLeanStd.Order::reverseList [Bytes] (prim list_fold (fun (acc : (List Bytes)) (item : Bytes) => (cons (tomlString item) acc)) (nil Bytes) values : (List Bytes))) (lit ", "))) (lit "]")), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: line, + parameters: [key : Bytes, shown : Bytes], + result: Bytes, + body: (cat (cat (cat key (lit " = ")) shown) 0x0a), + executable: true +} + +definition{ + name: stringLine, + parameters: [key : Bytes, value : Bytes], + result: Bytes, + body: (line key (tomlString value)), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: digestLine, + parameters: [key : Bytes, digest : Bytes], + result: Bytes, + body: (line key (tomlString (LexLeanStd.Numeral::hex digest))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: header, + parameters: [name : Bytes], + result: Bytes, + body: (cat (cat 0x0a name) 0x0a), + executable: true +} + +definition{ + name: escapedKey, + parameters: [text : Bytes], + result: Bytes, + body: (cat (LexLeanStd.Text::joinWith (LexLeanStd.Text::splitOn text (0 : UInt8)) 0x0001) 0x0000), + executable: true +} + +definition{ + name: pairsByPath, + parameters: [rows : (List (Bytes * Bytes))], + result: (List (Bytes * Bytes)), + body: (prim list_fold (fun (acc : (List (Bytes * Bytes))) (entry : (Bytes * (Bytes * Bytes))) => (cons (second entry) acc)) (nil (Bytes * Bytes)) (LexLeanStd.Order::reverseList [(Bytes * (Bytes * Bytes))] (LexLeanStd.Order::sortByKey [(Bytes * Bytes)] (LexLeanStd.Order::reverseList [(Bytes * (Bytes * Bytes))] (prim list_fold (fun (acc : (List (Bytes * (Bytes * Bytes)))) (row : (Bytes * Bytes)) => (cons ((first row), row) acc)) (nil (Bytes * (Bytes * Bytes))) rows : (List (Bytes * (Bytes * Bytes))))))) : (List (Bytes * Bytes))), + axioms: [propext], + executable: true +} + +definition{ + name: packageKey, + parameters: [row : LockPackage], + result: Bytes, + body: (cat (escapedKey (project row ident)) (escapedKey (project row version))), + executable: true +} + +definition{ + name: packagesSorted, + parameters: [rows : (List LockPackage)], + result: (List LockPackage), + body: (prim list_fold (fun (acc : (List LockPackage)) (entry : (Bytes * LockPackage)) => (cons (second entry) acc)) (nil LockPackage) (LexLeanStd.Order::reverseList [(Bytes * LockPackage)] (LexLeanStd.Order::sortByKey [LockPackage] (LexLeanStd.Order::reverseList [(Bytes * LockPackage)] (prim list_fold (fun (acc : (List (Bytes * LockPackage))) (row : LockPackage) => (cons ((packageKey row), row) acc)) (nil (Bytes * LockPackage)) rows : (List (Bytes * LockPackage)))))) : (List LockPackage)), + axioms: [propext], + executable: true +} + +definition{ + name: sourcesSorted, + parameters: [rows : (List LockSourcePackage)], + result: (List LockSourcePackage), + body: (prim list_fold (fun (acc : (List LockSourcePackage)) (entry : (Bytes * LockSourcePackage)) => (cons (second entry) acc)) (nil LockSourcePackage) (LexLeanStd.Order::reverseList [(Bytes * LockSourcePackage)] (LexLeanStd.Order::sortByKey [LockSourcePackage] (LexLeanStd.Order::reverseList [(Bytes * LockSourcePackage)] (prim list_fold (fun (acc : (List (Bytes * LockSourcePackage))) (row : LockSourcePackage) => (cons ((project row ident), row) acc)) (nil (Bytes * LockSourcePackage)) rows : (List (Bytes * LockSourcePackage)))))) : (List LockSourcePackage)), + axioms: [propext], + executable: true +} + +definition{ + name: pinText, + parameters: [table : Bytes, rows : (List (Bytes * Bytes))], + result: Bytes, + body: (prim list_fold (fun [table] (acc : Bytes) (row : (Bytes * Bytes)) => (cat acc (cat (cat (header table) (stringLine (lit "path") (first row))) (digestLine (lit "sha256") (second row))))) 0x (pairsByPath rows) : Bytes), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: packageText, + parameters: [row : LockPackage], + result: Bytes, + body: (cat (cat (cat (cat (cat (cat (cat (cat (header (lit "[[package]]")) (stringLine (lit "id") (project row ident))) (stringLine (lit "version") (project row version))) (stringLine (lit "kind") (project row kind))) (stringLine (lit "source") (project row origin))) (stringLine (lit "revision") (project row revision))) (digestLine (lit "tree_sha256") (project row treeSha256))) (digestLine (lit "manifest_sha256") (project row manifestSha256))) (line (lit "imports") (tomlArray (project row imports)))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: sourceText, + parameters: [row : LockSourcePackage], + result: Bytes, + body: (cat (cat (cat (cat (cat (cat (cat (cat (header (lit "[[source_package]]")) (stringLine (lit "id") (project row ident))) (stringLine (lit "version") (project row version))) (stringLine (lit "kind") (project row kind))) (stringLine (lit "source") (project row origin))) (stringLine (lit "module_prefix") (project row modulePrefix))) (digestLine (lit "tree_sha256") (project row treeSha256))) (digestLine (lit "manifest_sha256") (project row manifestSha256))) (line (lit "imports") (tomlArray (project row imports)))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: pdfText, + parameters: [entry : LockPdf], + result: Bytes, + body: (cat (cat (cat (cat (cat (cat (cat (header (lit "[pdf]")) (stringLine (lit "program") (project entry program))) (digestLine (lit "program_sha256") (project entry programSha256))) (line (lit "version_argv") (tomlArray (project entry versionArgv)))) (digestLine (lit "version_stdout_sha256") (project entry versionStdoutSha256))) (line (lit "compile_argv") (tomlArray (project entry compileArgv)))) (stringLine (lit "output") (project entry output))) (pinText (lit "[[pdf.resource]]") (project entry resources))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: canonicalLock, + parameters: [given : Lock], + result: Bytes, + body: (let spec : Bytes := (if (prim equal (project given language) (lit "1.2") : Bool) then (lit "lexlean/lock/2") else (lit "lexlean/lock/1")); (let head : Bytes := (cat (cat (cat (cat (stringLine (lit "spec") spec) (stringLine (lit "language") (project given language))) (digestLine (lit "compiler_semantics") (project given compilerSemantics))) (digestLine (lit "project_config_sha256") (project given projectConfigSha256))) (stringLine (lit "lean_toolchain") (leanToolchain))); (let pins : Bytes := (pinText (lit "[[workspace_file]]") (project given workspaceFiles)); (let rows : Bytes := (prim list_fold (fun (acc : Bytes) (row : LockPackage) => (cat acc (packageText row))) 0x (packagesSorted (project given packages)) : Bytes); (let sources : Bytes := (prim list_fold (fun (acc : Bytes) (row : LockSourcePackage) => (cat acc (sourceText row))) 0x (sourcesSorted (project given sourcePackages)) : Bytes); (let tail : Bytes := (match (project given pdf) + | Option.some entry => (pdfText entry) + | Option.none => 0x); (cat (cat (cat (cat head pins) rows) sources) tail))))))), + axioms: [Quot.sound, propext], + executable: true, + production: {effects: [allocation, overflow], targets: [rust-std]} +} +\end{semanticmodule} +\end{lexlean} diff --git a/tests/production-export/bootstrap/roots.json b/tests/production-export/bootstrap/roots.json index 4f911a0892..fcb6c89b24 100644 --- a/tests/production-export/bootstrap/roots.json +++ b/tests/production-export/bootstrap/roots.json @@ -24,6 +24,14 @@ ], "version": "1.0.0" }, + { + "name": "canonical_lock", + "root": "LexLeanBoot.LockText.canonicalLock", + "targets": [ + "rust-std" + ], + "version": "1.0.0" + }, { "name": "check_arguments", "root": "LexLeanBoot.CalculusCheck.checkArguments", @@ -216,6 +224,14 @@ ], "version": "1.0.0" }, + { + "name": "toml_string", + "root": "LexLeanBoot.LockText.tomlString", + "targets": [ + "rust-std" + ], + "version": "1.0.0" + }, { "name": "use_trees", "root": "LexLeanBoot.CalculusCheck.useTrees",