diff --git a/.github/release-gate.sh b/.github/release-gate.sh index c8344e3844..50330ebe56 100755 --- a/.github/release-gate.sh +++ b/.github/release-gate.sh @@ -45,10 +45,11 @@ whole_gate_passed() { local jobs=$1 part [ -n "$jobs" ] || return 1 printf '%s\n' "$jobs" | awk -F'\t' '$2 != "success" { bad = 1 } END { exit bad }' || return 1 - printf '%s\n' "$jobs" | grep -qxP 'atlas \(join\)\tsuccess\t.*' || return 1 + # Quiet grep can close the pipe early and make printf fail under pipefail. + printf '%s\n' "$jobs" | grep -xP 'atlas \(join\)\tsuccess\t.*' >/dev/null || return 1 [ "$(printf '%s\n' "$jobs" | grep -c '^build and non-Lean tests (')" -eq "$hosts" ] || return 1 for part in $parts; do - printf '%s\n' "$jobs" | grep -qP "^just vv \(\Q$part\E\)\tsuccess\t" || return 1 + printf '%s\n' "$jobs" | grep -P "^just vv \(\Q$part\E\)\tsuccess\t" >/dev/null || return 1 done } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 941fc6d5d1..e705569bb4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -829,10 +829,10 @@ jobs: # 41478333299), 124.5 of them in the conformance binary. #235 moves SP-02's # complete stress families and TC-03's seeded fuel sweep to the normative # host, keeping fixed vectors here, and reads the shared declaration - # inventory once in TC-03 and TC-05. The post-change Intel measurement is - # recorded with the PR's full-gate results before closing #235. This limit - # stays until that evidence supports lowering it: a timeout is a bound on - # a hung job, not a performance result. + # inventory once in TC-03 and TC-05. At 30612d265 on 2026-11-03 the + # post-change leg took 117m01s (run 41592896657), 100m21s in conformance. + # The 240-minute bound is about twice that observed runtime; no timeout + # reduction. timeout-minutes: 240 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/CONFORMANCE.md b/CONFORMANCE.md index e08d2a28c0..d8bb95e2f5 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -44,7 +44,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | --- | --- | --- | | `AU-01` | `build` | Every value of the closed semantic-module schema has one notation and the notation reads back to the value: every alternative of the declaration, term, type, and proof unions, with and without its optional members, is written and read back equal, a node that no readable form carries exactly is written generically, the notation is its own canonical form, and every committed semantic module is written and read back equal to its data. | | `AU-02` | `build` | A language-1.2 semantic module written in the authoring notation builds, with source maps that relate each declaration to its text in the notation; fmt leaves the notation unchanged and restores its canonical layout from another layout, and the notation under language 1.1 is refused with LLP2003; its data form is not a language-1.2 source (AU-13). | -| `AU-03` | `build` | Malformed notation fails closed and never panics: an unclosed delimiter, a keyword used as a name, a literal that is not canonical, an unknown kind, and every single-token deletion, duplication, and replacement of a committed module fail with a registered code at a position in the notation or link to a module that decodes, and a numeral with a redundant leading zero is LLL1003 outside a string and is not one inside it. | +| `AU-03` | `build` | Malformed notation fails closed and never panics: an unclosed delimiter, a keyword used as a name, a literal that is not canonical, an unknown kind, a readable term or type nested beyond the notation bound, and every single-token deletion, duplication, and replacement of a committed module fail with a registered code at a position in the notation or link to a module that decodes, and a numeral with a redundant leading zero is LLL1003 outside a string and is not one inside it. | | `AU-04` | `build` | No language-1.2 source of the product is written as data: every committed language-1.2 source with a semantic, tooling, or core module, in the compiler, the language libraries, the examples, and the positive fixtures, is written in the authoring notation and is canonical, the data form remains only under language 1.0 and 1.1 and in refused fixtures whose payload the notation cannot spell, and a refused fixture whose payload the notation can spell is a defect. | | `AU-05` | `build` | A language-1.2 tooling module written in the authoring notation renders, with source maps that relate each declaration to its text in the notation; the notation and the canonical JSON of every committed tooling module are in bijection and the notation is its own canonical form; fmt leaves the notation unchanged; and malformed notation, and every single-token deletion and duplication of a committed tooling module, fails with a position or decodes, and nothing panics. | | `AU-06` | `build` | The compiler-semantics ID does not depend on the form a module of the embedded tree is written in: a semantic, tooling, or core module in the authoring notation contributes its data form, so the committed tree and the same tree with every such module written as data have one ID, a change to a module's meaning changes the ID in either form, the identity a preservation record states for the native library is over the same data forms, so it is the committed one, and the embedded tree holds at least one module written in the notation. | @@ -571,7 +571,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `SM-09` | `build` | Linked IR has stable schema-tagged canonical JSON with alpha-safe binder serialization. | | `SM-10` | `build` | Source ID and semantic ID use exactly the specified framed hash inputs. | | `SM-11` | `build` | Linked project result sets contain every selected module and imported module exactly once in stable order. | -| `SM-12` | `build` | No semantic IR node can contain opaque prose, raw backend text, or an unknown extension. | +| `SM-12` | `build` | No semantic IR node can contain opaque prose, raw backend text, or an unknown extension. Semantic modules retain the 128-level JSON nesting limit and an over-deep list is refused with LLT4001 naming smaller definitions joined by prim append as the remedy. | | `SM-13` | `build` | Inherited section parameters are represented explicitly and emitted only on declarations that use them. | | `SM-14` | `build` | A numeral without a unique expected type is rejected rather than defaulted. | | `SM-15` | `build` | A native core module is closed typed DAG data shared by both backends, carries explicit declaration policies, and accepts no backend source text. | diff --git a/SPEC.md b/SPEC.md index daed99dbae..8a32e4950c 100644 --- a/SPEC.md +++ b/SPEC.md @@ -5412,8 +5412,12 @@ independent (1500, 3000, 7000, and 14000 trivial functions take 56, 101, 223, and 435 MB), before any limit of this section or of `max_ir_nodes` is reached; a chain of calls is the case above. And a semantic module is JSON read with the reader's recursion limit of 128 levels: a term nested deeper than that (a chain -of 130 nested `let`s) is `LLT4001`, `invalid semantic-module JSON: recursion -limit exceeded`, whatever `max_scope_depth` says; a chain of 100 is read. +of 130 nested `let`s) is `LLT4001` for excessive JSON nesting, whatever +`max_scope_depth` says; a chain of 100 is read. +The `LLT4001` nesting diagnostic names the unchanged 128-level bound and +recommends splitting long lists into smaller definitions joined by `prim append`. +It locates the semantic-module body, not the nested term; it does not report +coordinates in generated JSON as positions in the authored source. **Proof.** The proof follows the source term construct by construct through the library's compatibility lemmas. A recursive definition's relation is @@ -7416,7 +7420,9 @@ survive `fmt`. exact inverses over every committed module (`AU-08`, `AU-13`). - **Failing closed (`AU-03`).** Every single-token deletion, duplication, and replacement of a committed module either fails with a registered code or links - to a module that decodes. + to a module that decodes. Readable terms and types nested beyond the + notation bound are refused with `LLP2001` at the offending token, including + when their closing delimiters are missing. - **Tooling modules (`AU-05`).** The same laws for a tooling module: read and written back equal for every committed one, rendering with a source map that names the notation, `fmt` the identity on the notation, and every @@ -11074,7 +11080,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `SM-09` | `semantic-ir` | Linked IR has stable schema-tagged canonical JSON with alpha-safe binder serialization. | §17.9 | | `SM-10` | `semantic-ir` | Source ID and semantic ID use exactly the specified framed hash inputs. | §21.3, §21.4 | | `SM-11` | `semantic-ir` | Linked project result sets contain every selected module and imported module exactly once in stable order. | §17.5, §23.3 | -| `SM-12` | `semantic-ir` | No semantic IR node can contain opaque prose, raw backend text, or an unknown extension. | §6 I4, §17 | +| `SM-12` | `semantic-ir` | No semantic IR node can contain opaque prose, raw backend text, or an unknown extension. Semantic modules retain the 128-level JSON nesting limit and an over-deep list is refused with LLT4001 naming smaller definitions joined by prim append as the remedy. | §6 I4, §17 | | `SM-13` | `semantic-ir` | Inherited section parameters are represented explicitly and emitted only on declarations that use them. | §17.5, §18.3 | | `SM-14` | `semantic-ir` | A numeral without a unique expected type is rejected rather than defaulted. | §15.5 | | `SM-15` | `semantic-ir` | A native core module is closed typed DAG data shared by both backends, carries explicit declaration policies, and accepts no backend source text. | §17.10 | @@ -11397,7 +11403,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `TL-11` | `tooling` | Tooling modules are deterministic and content-addressed: each committed fixture's published build tree equals its golden byte for byte and across two clean builds in different directories, changing any declaration, registry row, source pin, or term changes the semantic ID, and the schema lies outside `schemas/` and so outside the compiler-semantics ID, which the committed locks of the three languages still record. | §17.20, §21.2, §28.3, §28.4 | | `AU-01` | `authoring` | Every value of the closed semantic-module schema has one notation and the notation reads back to the value: every alternative of the declaration, term, type, and proof unions, with and without its optional members, is written and read back equal, a node that no readable form carries exactly is written generically, the notation is its own canonical form, and every committed semantic module is written and read back equal to its data. | §17.21 | | `AU-02` | `authoring` | A language-1.2 semantic module written in the authoring notation builds, with source maps that relate each declaration to its text in the notation; fmt leaves the notation unchanged and restores its canonical layout from another layout, and the notation under language 1.1 is refused with LLP2003; its data form is not a language-1.2 source (AU-13). | §17.21 | -| `AU-03` | `authoring` | Malformed notation fails closed and never panics: an unclosed delimiter, a keyword used as a name, a literal that is not canonical, an unknown kind, and every single-token deletion, duplication, and replacement of a committed module fail with a registered code at a position in the notation or link to a module that decodes, and a numeral with a redundant leading zero is LLL1003 outside a string and is not one inside it. | §17.21 | +| `AU-03` | `authoring` | Malformed notation fails closed and never panics: an unclosed delimiter, a keyword used as a name, a literal that is not canonical, an unknown kind, a readable term or type nested beyond the notation bound, and every single-token deletion, duplication, and replacement of a committed module fail with a registered code at a position in the notation or link to a module that decodes, and a numeral with a redundant leading zero is LLL1003 outside a string and is not one inside it. | §17.21 | | `AU-04` | `authoring` | No language-1.2 source of the product is written as data: every committed language-1.2 source with a semantic, tooling, or core module, in the compiler, the language libraries, the examples, and the positive fixtures, is written in the authoring notation and is canonical, the data form remains only under language 1.0 and 1.1 and in refused fixtures whose payload the notation cannot spell, and a refused fixture whose payload the notation can spell is a defect. | §17.21 | | `AU-05` | `authoring` | A language-1.2 tooling module written in the authoring notation renders, with source maps that relate each declaration to its text in the notation; the notation and the canonical JSON of every committed tooling module are in bijection and the notation is its own canonical form; fmt leaves the notation unchanged; and malformed notation, and every single-token deletion and duplication of a committed tooling module, fails with a position or decodes, and nothing panics. | §17.20, §17.21 | | `AU-06` | `authoring` | The compiler-semantics ID does not depend on the form a module of the embedded tree is written in: a semantic, tooling, or core module in the authoring notation contributes its data form, so the committed tree and the same tree with every such module written as data have one ID, a change to a module's meaning changes the ID in either form, the identity a preservation record states for the native library is over the same data forms, so it is the committed one, and the embedded tree holds at least one module written in the notation. | §17.21, §21.2 | diff --git a/VERIFICATION.md b/VERIFICATION.md index 090cf8165e..eab5eef1fb 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -12275,6 +12275,52 @@ and fixtures. The three failing cases assert the count before their plants, so t run did not reach the plants on the new draws. A package that adds records should set these counts with its records in the tree, on the same commit. +## Policy failures are collected before publication (`VR-11`, #377) + +A language-1.2 module with two `join` definitions missing `propext` and a +`utf8_decode` definition understating its exact policy previously reported +only the first `LLV7005`, at `lexlean.toml:1:1`. Stage 11 now collects the +six policy-check sites and returns the existing canonically sorted failure +before extraction or publication. Missing audit records and process/internal +failures remain immediate. Semantic declaration anchors reuse the renderer's +notation/data source-range readers while the normalized sources are present. + +`VR-11` reuses its existing register row and adds this three-declaration +fixture, checking the actual JSON command, source slices and absence +of verified output. The regression deliberately performs one verification; +the generic diagnostic formatter and limiter are unchanged. + +On Linux x86-64 with Lean 4.32.1 from the configured `ELAN_HOME`, direct CLI +runs reported all three diagnostics at `src/Main.lex.tex` lines 5, 13 and 21, +in both output formats (human run: 6.85 s). A one-off configuration with +`max_diagnostics = 1` retained the first violation and reported `LLS8002`, +configured 1, observed 3 (7.48 s); keeping only the third declaration gave +one `LLV7005` at its source declaration (7.17 s). None published an +attestation. The pre-fix CLI output contained only the first diagnostic. + +The focused renderer/runtime compiler-semantics fingerprint tests pass (two +tests), and `conformance_rp_10` passes its embedded/disk identity and lock +checks (6.33 s). All-target/all-feature checks and Clippy with warnings denied +pass for `lexlean` and `repo-conformance`. This changes no embedded normative +file or fingerprinted renderer +source, so no compiler-semantics pin or artifact regeneration is needed. +The full Lean-backed `VR-11` case was not run here: its host helper requires +the toolchain under `HOME/.elan`, whereas this environment installs it under +`/workspace/.setup/elan`; the direct CLI evidence above uses that installation +without changing the host helper or home directory. + +The first PR #403 honesty run (41605700268, job 125814846351) caught +an eight-step `VR-11` scenario; the Gherkin subset permits at most six. +The same failure reproduced locally. Consolidating the related subset-policy +outcomes and the multi-diagnostic outcome into six steps retains every stated +expectation and leaves the gate unchanged. All five tests of +`cargo test --locked -p repo-conformance --test bdd` then pass, including +its planted-defect falsifiability test. CI run 41605700263 also passed the +complete `bdd-verification` leg on the original implementation, including +`VR-11`. That run's separate `bdd-compiler` leg failed with a stack overflow +in `conformance_tc_03`; this scenario correction does not establish a full +gate pass. + ### Host-matrix cost and coverage (#235) The successful Intel macOS job 125390659100 of run 41478333299 at @@ -12307,6 +12353,124 @@ helper requires `$HOME/.elan`. That is a blocked Lean-backed test, not a pass or an Intel timing measurement. The full normative cases and actual non-normative host paths remain for CI; neither helper nor home was changed. + +## Readable semantic notation obeys its nesting bound (AU-03, #374) + +The recursive readable term and type readers enforce the same depth-256 bound +as the generic notation reader. `conformance_au_03` constructs 50,000-level +`cons` terms and `List` types, both with and without their closing parentheses. +The public check API and the CLI in human and JSON modes must refuse each with +`LLP2001` at a position in `src/Main.lex.tex`, before decoding semantic JSON. +These are temporary negative projects inside the existing AU-03 case. + +`cargo test -p lexlean --lib readable_nesting_has_an_explicit_bound` also checks +the exact readable boundary: 255 unary terms or `List` types, and 254 `cons` +terms ending in `(nil Nat)`, read successfully; one more nesting is refused. +The leaf type of `nil` consumes the additional level. + +The test failed on the old reader because an over-bound term was accepted. +Removing only the readable term guard then failed on the 256-level unary term; +removing only the type guard failed on the over-bound `cons` term's leaf type. +Both plants returned a failing test (exit 101), without a stack abort, and were +restored. The fixed boundary test and `conformance_au_03` passed on Linux with +Rust 1.97.1. No Lean process is involved in these checks. + +The fix changes no embedded normative identity input: `build.rs` embeds +`language/`, `schemas/`, and the axiom-parser and canonical-JSON goldens, none +of which changes here. No language identity or verification oracle is rewritten. + +## Semantic JSON nesting diagnostic names the list workaround (`SM-12`, #375) + +The 128-level semantic JSON reader limit is unchanged. Before the diagnostic +change, `cargo test --offline --locked -p repo-conformance --test conformance +conformance_sm_12 -- --exact --nocapture` failed on the new assertion with: + +```text +phase link: invalid semantic-module JSON: recursion limit exceeded at line 1 column 6925 +``` + +The committed fixtures under `tests/semantic-json-depth/` exercise a 122-cell +list that checks, a 123-cell list that fails, the same failure in a subsequent +declaration, and a 200-cell list split into two definitions joined by +`prim append` that checks. The failure is checked through the project API, +human and JSON CLI output, and the semantic JSON reader directly. Malformed, +noncanonical, duplicate-member and out-of-schema data (including an extra +member on a tagged unit variant) remain refused without list-depth advice. +The source span still covers the module body; generated JSON coordinates are +not presented as a nested term's source position. + +After the change, the same command passes (1.83 s on this host). Removing +the append recommendation from the diagnostic, leaving the bound and +smaller-definitions advice intact, makes that command +fail on its `prim append` assertion (1.32 s). The planted edit was restored. +The diagnostic change does not run Lean or establish a new verification claim; +#375 already records verification of two 100-cell lists joined by append. + +The nesting diagnostic retains the existing `recursion limit exceeded` category, +which the `SP-02` 130-level let-chain refusal also asserts. Only its generated +JSON coordinates are replaced by the bound and workaround advice. + +## Release evidence consumes the whole jobs listing (RP-18, #408) + +The release gate piped the jobs listing into quiet `grep` with `pipefail` +set. A match can close the pipe before `printf` finishes, so a complete +passing listing can be refused because its producer receives SIGPIPE. +The Atlas-join and required-leg checks now consume all input and discard +matching output. Their patterns, the all-success check, host count, tree +comparison, and required-leg set are unchanged. + +`release_gate_decisions` now appends 1,500 successful jobs to the complete +fixture and requires acceptance, then appends a failed job after every +required row and requires refusal with no evidence file. Before the script +fix, the new large-list assertion failed with `left: 1`, `right: 0` and +`release-gate: no run of ci.yml was the whole gate and passed every job`. +With the fix, that assertion and every existing decision pass. These +red/green checks ran the unchanged function extracted into a standalone +Rust executable linked to the workspace's existing dependency artifacts; +no Cargo rebuild or full acceptance run is claimed by this record. +Shell syntax, Rust formatting, and diff whitespace checks pass. + +This independently reproduced listing-size defect is not established as +the cause of PR #403's CI RP-18 failure on its ordinary fixture. That +ordinary case also passed locally before this correction. + +The first full PR gate (run 41621446939, job 125870930417) exposed that the +two deliberately refused 123-cell sources were outside the corpus's `negative/` +classification. A focused local `conformance_au_08` reproduced the refusal at +`authoring.rs:1276` in 138.28 s. Those two unchanged sources now live in +`tests/semantic-json-depth/negative/`, and `SM-12` reads their new paths. The +122-cell and split-list sources retain their positive placement. `AU-08`'s +reader, corpus walk, round trips and anti-vacuity assertions are unchanged; +its existing negative classification still attempts to read every source and +applies every round-trip assertion whenever reading succeeds. `SM-12` retains +every project, API, CLI and direct-reader refusal assertion. + +After the placement correction, the same focused `conformance_au_08` command +passes in 723.03 s and `conformance_sm_12` passes in 1.91 s. Formatting and +`git diff --check` pass. No identity input or generated record changed. + +## Policy source anchors reuse the rendered declaration mappings (#377) + +Stage 11 now takes language-1.2 semantic declaration ranges from the existing +Lean artifact mappings whose node kind is `semantic-declaration`. The renderer +emits one such piece per source declaration in declaration order, including +its separating newline; source-map folding orders the pieces by artifact and +generated byte range. Filtering to Lean avoids the corresponding LaTeX rows. +The legacy `semantic-module/1` renderer has only a whole-module node, so its +existing source lookup remains intact. No source-map or backend bytes change. + +The direct three-policy CLI fixture was verified once with pinned Lean +4.32.1 after this refactor. It returned three `LLV7005` diagnostics and no +artifacts. Its entire diagnostics array equals the earlier direct CLI result: +`first` maps to source bytes 113..251 (line 5), `second` to 253..392 (line 13), +and `third` to 394..564 (line 21), all at column 1. Each slice contains its own +named declaration. The CLI build and lexlean all-target/all-feature Clippy +with warnings denied pass, as do formatting and diff whitespace checks. + +This removes a redundant parse; it does not establish or resolve the cause of +PR #403's earlier TC-03 CI stack overflow. No full acceptance run is claimed +by this local check. + ## The canonical LaTeX of a tooling module is language-1.2 source (`BS-20`, #270) `bootstrap/src/ToolingAst.lex.tex` holds the closed schema of the tooling module diff --git a/crates/conformance/src/cases/authoring.rs b/crates/conformance/src/cases/authoring.rs index 3ae31b3851..8989617e1b 100644 --- a/crates/conformance/src/cases/authoring.rs +++ b/crates/conformance/src/cases/authoring.rs @@ -471,6 +471,53 @@ fn fails_closed() { assert!(span.line_start >= 1, "{what}: no line"); } } + // Recursive readable forms bypass the generic reader; their own bound + // must fire before either serde's recursion limit or a host stack abort. + for (prefix, leaf, position) in [ + ("(cons 1 ", "(nil Nat)", "body"), + ("(List ", "Nat", "result"), + ] { + let nested = format!("{}{}{}", prefix.repeat(50_000), leaf, ")".repeat(50_000)); + let declaration = if position == "body" { + format!( + "definition{{name: deep, parameters: [], result: (List Nat), body: {nested}}}\n" + ) + } else { + format!("definition{{name: deep, parameters: [], result: {nested}, body: 0}}\n") + }; + for text in [ + declaration.clone(), + declaration.replacen(&nested, &nested.replace(')', ""), 1), + ] { + put_body(&project, &text); + let error = project.check_err(); + let diagnostic = &error.diagnostics[0]; + assert_eq!(diagnostic.code.as_str(), "LLP2001"); + assert!( + diagnostic.message.contains("nested more deeply"), + "{diagnostic:?}" + ); + let span = diagnostic.primary.as_ref().expect("notation position"); + assert_eq!(span.path.as_str(), MAIN); + assert!(span.column_start > 256); + let (exit, _, stderr) = project.cli(&["check"]); + assert_eq!(exit, 1, "{stderr}"); + assert!( + stderr.contains("LLP2001") && stderr.contains(MAIN), + "{stderr}" + ); + let (exit, stdout, stderr) = project.cli(&["check", "--diagnostic-format", "json"]); + assert_eq!(exit, 1, "{stderr}"); + let result: serde_json::Value = + serde_json::from_str(&stdout).expect("JSON command result"); + assert_eq!(result["diagnostics"][0]["code"], "LLP2001"); + assert_eq!(result["diagnostics"][0]["primary"]["path"], MAIN); + assert_eq!( + result["diagnostics"][0]["primary"]["column_start"], + span.column_start + ); + } + } put_body(&project, &original); project.check_ok(); diff --git a/crates/conformance/src/cases/repository.rs b/crates/conformance/src/cases/repository.rs index 4237ccd569..042d563674 100644 --- a/crates/conformance/src/cases/repository.rs +++ b/crates/conformance/src/cases/repository.rs @@ -3066,6 +3066,18 @@ fn release_gate_decisions() { Ok(()), "the evidence satisfies the release criterion" ); + // A complete listing can exceed a pipe buffer as the workflow grows. + // Matching a required row must still consume the rest of the listing. + let mut large = green.clone(); + large.extend( + (0..1500).map(|index| stamp(&format!("additional successful job {index}"), "success")), + ); + let (code, _, stderr) = decide(&head, &[(head.as_str(), run_line("19"))], &large); + assert_eq!(code, 0, "a large complete gate is accepted: {stderr}"); + large.push(stamp("a failed job after every required row", "failure")); + let (code, evidence, stderr) = decide(&head, &[(head.as_str(), run_line("20"))], &large); + assert_eq!(code, 1, "a late failed job is refused: {stderr}"); + assert!(evidence.is_empty(), "a late failure writes no evidence"); // The merge of a head whose tree it lands unchanged: the head's run. let (code, evidence, stderr) = decide(&merge_equal, &[(head.as_str(), run_line("12"))], &green); assert_eq!( diff --git a/crates/conformance/src/cases/semantic_ir.rs b/crates/conformance/src/cases/semantic_ir.rs index 1c003e0b2d..eb6aa60c5d 100644 --- a/crates/conformance/src/cases/semantic_ir.rs +++ b/crates/conformance/src/cases/semantic_ir.rs @@ -13,6 +13,99 @@ mod names; mod strings; mod widen; +fn semantic_json_depth_diagnostic() { + let project = P::example(); + project.edit("lexlean.toml", "language = \"1.0\"", "language = \"1.2\""); + // Direct reader assertions use the same configured stack as the pipeline. + let stack_bytes = support::limits_of(&project) + .compile_stack_plan() + .stack_bytes; + std::thread::Builder::new() + .stack_size(stack_bytes) + .spawn(move || semantic_json_depth_diagnostic_on_stack(&project)) + .expect("reader test thread") + .join() + .expect("semantic JSON depth assertions"); +} + +fn semantic_json_depth_diagnostic_on_stack(project: &P) { + let fixture = |name: &str| { + std::fs::read_to_string( + support::repo_root() + .join("tests/semantic-json-depth") + .join(name), + ) + .expect("committed semantic JSON depth fixture") + }; + for name in ["list-122.lex.tex", "split-list-200.lex.tex"] { + project.write("src/Main.lex.tex", &fixture(name)); + project.relock(); + project.check_ok(); + } + let parse_data = |data: &str| { + lexlean::ir::semantic::SemanticModule::parse( + data, + "1.2", + "LexLeanExample", + &[], + &std::collections::BTreeMap::new(), + &lexlean::ir::semantic::model::ArtifactStore::new(u64::MAX, u64::MAX), + ) + }; + for name in [ + "negative/list-123.lex.tex", + "negative/later-list-123.lex.tex", + ] { + let source = fixture(name); + project.write("src/Main.lex.tex", &source); + project.relock(); + let error = project.check_fails_with("LLT4001"); + let message = &error.diagnostics[0].message; + assert!(message.contains("128-level"), "{message}"); + assert!(message.contains("recursion limit exceeded"), "{message}"); + assert!(message.contains("smaller definitions"), "{message}"); + assert!(message.contains("prim append"), "{message}"); + assert!( + !message.contains("column"), + "generated JSON coordinates are not source positions: {message}" + ); + let data_form = lexlean::sdk::to_data_form(&source).expect("notation writes to data form"); + let data = data_form + .split_once("\\semanticdata{") + .expect("semantic data") + .1 + .split_once("}\n\\end{semanticmodule}") + .expect("module end") + .0; + let failure = parse_data(data).expect_err("same bound on semantic JSON input"); + assert_eq!(failure.code.as_str(), "LLT4001"); + assert!(failure.reason.contains("prim append")); + for arguments in [vec!["check"], vec!["check", "--diagnostic-format", "json"]] { + let (code, stdout, stderr) = project.cli(&arguments); + assert_ne!(code, 0); + assert!(format!("{stdout}{stderr}").contains("prim append")); + } + } + + let empty = r#"{"declarations":[],"spec":"lexlean/semantic-module/2"}"#; + let invalid = [ + empty.replace(",\"spec\"", " \"spec\""), + empty.replace("{\"declarations\"", "{ \"declarations\""), + empty.replace("\"spec\":", "\"spec\":\"lexlean/semantic-module/2\",\"spec\":"), + empty.replace("\"declarations\":[]", "\"declarations\":[],\"foreign\":true"), + r#"{"declarations":[{"body":{"kind":"nat","prose":"foreign","value":"1"},"kind":"definition","name":"x","parameters":[],"result":{"kind":"nat"}}],"spec":"lexlean/semantic-module/2"}"#.to_owned(), + ]; + for data in invalid { + let error = + parse_data(&data).expect_err("malformed, noncanonical or foreign data stays refused"); + assert_eq!(error.code.as_str(), "LLT4001"); + assert!( + !error.reason.contains("prim append"), + "depth advice belongs only to nesting failures: {error}" + ); + } +} + /// Every `"k"` and `"kind"` tag value in a canonical JSON document. fn collect_tags(value: &serde_json::Value, key: &str, out: &mut BTreeSet) { match value { @@ -692,6 +785,7 @@ pub(crate) fn run(id: &str) { } // §17.5, I7: no opaque prose inside semantic IR. "SM-12" => { + semantic_json_depth_diagnostic(); let project = P::example(); let json = support::checked_project(&project) .linked_json() diff --git a/crates/conformance/src/cases/verification.rs b/crates/conformance/src/cases/verification.rs index 3cbe4020a9..237b494957 100644 --- a/crates/conformance/src/cases/verification.rs +++ b/crates/conformance/src/cases/verification.rs @@ -28,6 +28,65 @@ fn process_records(dir: &camino::Utf8Path) -> Vec { .collect() } +/// One audit must report every user policy violation before publication (#377). +fn multiple_policy_violations() { + let _guard = support::env_shared(); + let project = P::example(); + project.edit("lexlean.toml", "language = \"1.0\"", "language = \"1.2\""); + let source = r#"\begin{lexlean}{Main} +\useglossary{lexlean.std.nat@1.2.0} +\title{Natural number addition} +\begin{semanticmodule} +definition{ + name: first, + parameters: [xs : (List String)], + result: String, + body: (prim join xs "," : String), + executable: true +} + +definition{ + name: second, + parameters: [xs : (List String)], + result: String, + body: (prim join xs ";" : String), + executable: true +} + +definition{ + name: third, + parameters: [b : Bytes], + result: (Option String), + body: (prim utf8_decode b : (Option String)), + executable: true, + axioms: [propext] +} +\end{semanticmodule} +\end{lexlean} +"#; + project.write("src/Main.lex.tex", source); + project.relock(); + let (exit, json, stderr) = project.cli(&["verify", "--diagnostic-format", "json"]); + assert_eq!(exit, 1, "{stderr}"); + let json: serde_json::Value = serde_json::from_str(&json).expect("JSON command result"); + let diagnostics = json["diagnostics"].as_array().expect("diagnostics"); + assert_eq!(diagnostics.len(), 3, "every policy failure: {json}"); + for (diagnostic, name) in diagnostics.iter().zip(["first", "second", "third"]) { + assert_eq!(diagnostic["code"], "LLV7005"); + assert!(diagnostic["message"] + .as_str() + .expect("message") + .contains(&format!(".Main.{name}`"))); + let span = &diagnostic["primary"]; + assert_eq!(span["path"], "src/Main.lex.tex"); + let start = span["byte_start"].as_u64().expect("start") as usize; + let end = span["byte_end"].as_u64().expect("end") as usize; + assert!(source[start..end].contains(&format!("name: {name},"))); + assert!(end - start < source.len() / 2); + } + assert!(support::file_set(&project.root.join(".lexlean/verified")).is_empty()); +} + /// The cases whose assertions need the pinned toolchain (§8.3); every /// other case is platform independent and runs on every supported host. const LEAN_BACKED: [&str; 14] = [ @@ -634,6 +693,7 @@ pub(crate) fn run(id: &str) { } // §22.6: policies enforced exactly and recorded per declaration. "VR-11" => { + multiple_policy_violations(); let attestation = &support::verified().attestation; let declarations = attestation["declarations"].as_array().expect("policy rows"); let row = declarations diff --git a/crates/lexlean/src/ir/semantic.rs b/crates/lexlean/src/ir/semantic.rs index 9ef7d22731..d8563ffe68 100644 --- a/crates/lexlean/src/ir/semantic.rs +++ b/crates/lexlean/src/ir/semantic.rs @@ -8815,8 +8815,15 @@ impl SemanticModule { imported_modules: &BTreeMap, artifacts: &model::ArtifactStore, ) -> Result { - let module: Self = serde_json::from_str(text) - .map_err(|error| format!("invalid semantic-module JSON: {error}"))?; + let module: Self = serde_json::from_str(text).map_err(|error| { + // The notation has already become JSON, so serde's coordinates + // cannot locate the offending term in the authored source. + if error.to_string().starts_with("recursion limit exceeded") { + "invalid semantic-module JSON: recursion limit exceeded (128-level semantic JSON bound); split long lists into smaller definitions joined by `prim append`".to_owned() + } else { + format!("invalid semantic-module JSON: {error}") + } + })?; let canonical = crate::artifact::canonical_json::Json::parse(text.as_bytes())?.to_canonical_string(); if canonical != text { diff --git a/crates/lexlean/src/surface/semantic.rs b/crates/lexlean/src/surface/semantic.rs index c6d61f9160..aeffe1343e 100644 --- a/crates/lexlean/src/surface/semantic.rs +++ b/crates/lexlean/src/surface/semantic.rs @@ -574,6 +574,9 @@ mod types { /// Read a type. pub(super) fn read(reader: &mut Reader<'_>, depth: usize) -> Result { + if depth > super::MAX_DEPTH { + return Err(reader.error("nested more deeply than the notation reads")); + } let offset = reader.offset(); match reader.peek() { Some(Token::Word(word)) => { @@ -1150,6 +1153,9 @@ mod terms { /// Read a term. pub(super) fn read(reader: &mut Reader<'_>, depth: usize) -> Result { + if depth > super::MAX_DEPTH { + return Err(reader.error("nested more deeply than the notation reads")); + } let offset = reader.offset(); match reader.peek() { Some(Token::Str(text)) => { @@ -1855,6 +1861,34 @@ mod tests { text } + #[test] + fn readable_nesting_has_an_explicit_bound() { + std::thread::Builder::new() + .stack_size(crate::READER_STACK) + .spawn(|| { + for (position, prefix, leaf, bound) in [ + (Position::Term, "(not ", "true", 255), + (Position::Term, "(cons 1 ", "(nil Nat)", 254), + (Position::Type, "(List ", "Nat", 255), + ] { + let at_bound = format!("{}{}{}", prefix.repeat(bound), leaf, ")".repeat(bound)); + assert!(parse_at(&at_bound, position).is_ok()); + let beyond = format!( + "{}{}{}", + prefix.repeat(bound + 1), + leaf, + ")".repeat(bound + 1) + ); + let error = parse_at(&beyond, position).expect_err("nesting must be bounded"); + assert_eq!(error.message, "nested more deeply than the notation reads"); + assert!(error.offset > 0 && error.offset < beyond.len()); + } + }) + .expect("reader thread") + .join() + .expect("reader must not panic"); + } + /// The readable forms print as the SPEC says they do, and parse back. #[test] fn readable_forms() { diff --git a/crates/lexlean/src/verify/mod.rs b/crates/lexlean/src/verify/mod.rs index 1efe001374..498053eb77 100644 --- a/crates/lexlean/src/verify/mod.rs +++ b/crates/lexlean/src/verify/mod.rs @@ -1137,6 +1137,41 @@ pub fn run_part( declaration_spans.insert(full_name, span); } } + if let Some(semantic) = &document.semantic { + // The v2 renderer emits one Lean mapping per semantic declaration, + // ordered by generated offset. Reuse those checked source ranges + // instead of parsing the same normalized notation again. + let ranges: Vec<_> = if semantic.spec == "lexlean/semantic-module/2" { + module + .map + .mappings + .iter() + .filter(|mapping| { + module.map.artifacts[mapping.artifact].kind + == crate::artifact::source_map::ArtifactKind::Lean + && module.map.nodes[mapping.node].kind == "semantic-declaration" + }) + .filter_map(|mapping| mapping.src_range) + .collect() + } else { + // Legacy v1 maps only the whole module, so keep its source lookup. + let normalized = &checked.modules[&module.module].normalized; + crate::backend::semantic::notation_declaration_spans(normalized, "semanticmodule") + .or_else(|| { + crate::backend::semantic::declaration_spans_in( + normalized, + "\\semanticdata{", + ) + }) + .unwrap_or_default() + }; + for (declaration, range) in semantic.declarations.iter().zip(ranges) { + declaration_spans.insert( + format!("{}.{}", module.lean_module, declaration.name()), + source_span(checked, module, range), + ); + } + } } // Generated-source audit before any Lean invocation (§18.2): the build @@ -1974,13 +2009,20 @@ pub fn run_part( stages.enter("policy"); // Stage 11: per-declaration policy enforcement (§22.6). let mut declaration_rows: Vec = Vec::new(); + let mut policy_diagnostics = Vec::new(); + let mut reject_policy = |name: &str, mut diagnostic: Diagnostic| { + if let Some(span) = declaration_spans.get(name) { + diagnostic = diagnostic.with_span(span.clone()); + } + policy_diagnostics.push(diagnostic); + }; for module in &build.modules { let document = &checked.modules[&module.module].document; for declaration in document.declarations() { let full_name = format!("{}.{}", module.lean_module, declaration.lean_name); let observed_set = observed.get(&full_name).cloned().unwrap_or_default(); if !declaration.policy.permits(&observed_set) { - let mut diagnostic = Diagnostic::new( + let diagnostic = Diagnostic::new( code!("LLV7005"), format!( "`{full_name}` violates its {} axiom policy: observed [{}]", @@ -1988,10 +2030,7 @@ pub fn run_part( observed_set.join(", ") ), ); - if let Some(span) = declaration_spans.get(&full_name).cloned() { - diagnostic = diagnostic.with_span(span); - } - return Err(fail(diagnostic)); + reject_policy(&full_name, diagnostic); } declaration_rows.push(Json::object(vec![ ("name", Json::Str(full_name)), @@ -2026,15 +2065,18 @@ pub fn run_part( continue; }; if !declaration.policy.permits(&observed_set) { - return Err(fail(Diagnostic::new( - code!("LLV7005"), - format!( - "`{}` violates its {} axiom policy: observed [{}]", - declaration.name, - declaration.policy.kind(), - observed_set.join(", ") + reject_policy( + &declaration.name, + Diagnostic::new( + code!("LLV7005"), + format!( + "`{}` violates its {} axiom policy: observed [{}]", + declaration.name, + declaration.policy.kind(), + observed_set.join(", ") + ), ), - ))); + ); } declaration_rows.push(Json::object(vec![ ("name", Json::Str(declaration.name.clone())), @@ -2102,7 +2144,7 @@ pub fn run_part( .iter() .any(|axiom| !declaration.axioms().contains(axiom)) { - return Err(fail(Diagnostic::new( + reject_policy(&format!("{}.{}", module.lean_module, declaration.name()), Diagnostic::new( code!("LLV7005"), format!( "`{full_name}`, generated by `{}`, violates its {} axiom policy: observed [{}]", @@ -2110,7 +2152,7 @@ pub fn run_part( declaration.axiom_policy_kind(), observed_set.join(", ") ), - ))); + )); } union.extend(observed_set.iter().cloned()); declaration_rows.push(Json::object(vec![ @@ -2140,7 +2182,7 @@ pub fn run_part( ])); } if union.into_iter().collect::>() != declaration.axioms() { - return Err(fail(Diagnostic::new( + reject_policy(&format!("{}.{}", module.lean_module, declaration.name()), Diagnostic::new( code!("LLV7005"), format!( "`{}.{}` violates its {} axiom policy: its generated declarations observe exactly a different set", @@ -2148,7 +2190,7 @@ pub fn run_part( declaration.name(), declaration.axiom_policy_kind() ), - ))); + )); } continue; } @@ -2159,14 +2201,17 @@ pub fn run_part( ))) })?; if observed_set != declaration.axioms() { - return Err(fail(Diagnostic::new( - code!("LLV7005"), - format!( - "`{full_name}` violates its {} axiom policy: observed [{}]", - declaration.axiom_policy_kind(), - observed_set.join(", ") + reject_policy( + &full_name, + Diagnostic::new( + code!("LLV7005"), + format!( + "`{full_name}` violates its {} axiom policy: observed [{}]", + declaration.axiom_policy_kind(), + observed_set.join(", ") + ), ), - ))); + ); } declaration_rows.push(Json::object(vec![ ("name", Json::Str(full_name)), @@ -2210,14 +2255,14 @@ pub fn run_part( ))) })?; if observed_set != *axioms { - return Err(fail(Diagnostic::new( + reject_policy(name, Diagnostic::new( code!("LLV7005"), format!( "`{name}` of the runtime module `{}` violates its exact axiom policy: observed [{}]", module.name, observed_set.join(", ") ), - ))); + )); } declaration_rows.push(Json::object(vec![ ("name", Json::Str(name.clone())), @@ -2240,6 +2285,10 @@ pub fn run_part( } } + if !policy_diagnostics.is_empty() { + return Err(LexLeanError::from_diagnostics(policy_diagnostics)); + } + stages.enter("extraction"); // Stage 12: named-root extraction (§22.10). Lean's compiler front end // reports the computational closure of every production root while the diff --git a/features/suites/authoring.feature b/features/suites/authoring.feature index 44ffc97b43..efa12a540a 100644 --- a/features/suites/authoring.feature +++ b/features/suites/authoring.feature @@ -13,7 +13,7 @@ Feature: authoring Then each builds, the source maps relate each declaration to its text in the notation, fmt leaves the notation unchanged and restores the layout, and language 1.1 refuses it @AU-03 @build - Scenario: Malformed notation fails closed and never panics: an unclosed delimiter, a keyword used as a name, a literal that is not canonical, an unknown kind, and every single-token deletion, duplication, and replacement of a committed module fail with a registered code at a position in the notation or link to a module that decodes, and a numeral with a redundant leading zero is LLL1003 outside a string and is not one inside it. + Scenario: Malformed notation fails closed and never panics: an unclosed delimiter, a keyword used as a name, a literal that is not canonical, an unknown kind, a readable term or type nested beyond the notation bound, and every single-token deletion, duplication, and replacement of a committed module fail with a registered code at a position in the notation or link to a module that decodes, and a numeral with a redundant leading zero is LLL1003 outside a string and is not one inside it. Given a committed language-1.2 module in the notation When it is malformed in each way named, and each of its tokens is deleted, duplicated, and replaced in turn, and numerals with a redundant leading zero are written outside and inside a string Then each is refused with a registered code at a position or links to a module that decodes, nothing panics, and only the numeral outside a string is LLL1003 diff --git a/features/suites/semantic-ir.feature b/features/suites/semantic-ir.feature index c18373d035..e065e67fb5 100644 --- a/features/suites/semantic-ir.feature +++ b/features/suites/semantic-ir.feature @@ -78,10 +78,12 @@ Feature: semantic-ir And the `All` selection returns the same complete sorted set @SM-12 @build - Scenario: No semantic IR node can contain opaque prose, raw backend text, or an unknown extension. + Scenario: No semantic IR node can contain opaque prose, raw backend text, or an unknown extension. Semantic modules retain the 128-level JSON nesting limit and an over-deep list is refused with LLT4001 naming smaller definitions joined by prim append as the remedy. Given the example project checked through the internal pipeline When the linked IR is serialized to canonical JSON Then the JSON contains none of `natural number`, `For every`, `reflexivity`, or `Close the goal` + And a 122-element list checks while a 123-element list, including in a subsequent declaration, fails with LLT4001 naming the 128-level JSON bound and smaller definitions joined by prim append + And two 100-element definitions joined by prim append check, and malformed, noncanonical, duplicate-member and out-of-schema data remain refused @SM-13 @build Scenario: Inherited section parameters are represented explicitly and emitted only on declarations that use them. diff --git a/features/suites/verification.feature b/features/suites/verification.feature index 0444b94c7e..98b176bec9 100644 --- a/features/suites/verification.feature +++ b/features/suites/verification.feature @@ -75,12 +75,12 @@ Feature: verification @VR-11 @build Scenario: None, allow-subset, and exact axiom policies are enforced exactly and recorded per declaration. - Given the attestation of the verified nat-add-zero example under \noaxioms - When the declarations row for LexLeanExample.Main.add_zero is read - Then its policy kind is `none` and its observed set is empty - And the em fixture verified under \allowaxioms{Classical.choice;Quot.sound;propext} records the sorted observed set Classical.choice, Quot.sound, propext - And the same em fixture under \allowaxioms{Classical.choice} fails with LLV7005 naming the excess propext and Quot.sound + Given the verified nat-add-zero example under \noaxioms and the em and language-1.2 policy fixtures + When their declaration policies are verified and the attestation rows and diagnostics are read + Then LexLeanExample.Main.add_zero records policy kind `none` and an empty observed set + And the em fixture under \allowaxioms{Classical.choice;Quot.sound;propext} records that sorted observed set, while \allowaxioms{Classical.choice} fails with LLV7005 naming the excess propext and Quot.sound And an exact policy passes only when the observed set matches and fails with LLV7005 on any mismatch + And three wrong language-1.2 declaration policies report all three LLV7005 diagnostics in source order in JSON output, each at its declaration source span, and publish no verified artifact @VR-12 @build Scenario: Child process output is normalized with the exact path and line rules before hashing. diff --git a/model/ids.toml b/model/ids.toml index e1f5ddc29a..c242b773a5 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -575,7 +575,7 @@ statement = "Linked project result sets contain every selected module and import id = "SM-12" level = "build" suite = "semantic-ir" -statement = "No semantic IR node can contain opaque prose, raw backend text, or an unknown extension." +statement = "No semantic IR node can contain opaque prose, raw backend text, or an unknown extension. Semantic modules retain the 128-level JSON nesting limit and an over-deep list is refused with LLT4001 naming smaller definitions joined by prim append as the remedy." [[id]] id = "SM-13" @@ -2507,7 +2507,7 @@ statement = "A language-1.2 semantic module written in the authoring notation bu id = "AU-03" level = "build" suite = "authoring" -statement = "Malformed notation fails closed and never panics: an unclosed delimiter, a keyword used as a name, a literal that is not canonical, an unknown kind, and every single-token deletion, duplication, and replacement of a committed module fail with a registered code at a position in the notation or link to a module that decodes, and a numeral with a redundant leading zero is LLL1003 outside a string and is not one inside it." +statement = "Malformed notation fails closed and never panics: an unclosed delimiter, a keyword used as a name, a literal that is not canonical, an unknown kind, a readable term or type nested beyond the notation bound, and every single-token deletion, duplication, and replacement of a committed module fail with a registered code at a position in the notation or link to a module that decodes, and a numeral with a redundant leading zero is LLL1003 outside a string and is not one inside it." [[id]] id = "AU-04" diff --git a/tests/semantic-json-depth/README.md b/tests/semantic-json-depth/README.md new file mode 100644 index 0000000000..b612b5af49 --- /dev/null +++ b/tests/semantic-json-depth/README.md @@ -0,0 +1,16 @@ +# Semantic JSON depth fixtures + +`SM-12` reads these authored language-1.2 modules in a temporary project with +`max_scope_depth = 1024`. The semantic JSON reader still has its documented +128-level nesting limit: 122 `cons` cells check, while 123 fail with `LLT4001` +and advice to use smaller definitions joined by `prim append`. + +The refused sources live under `negative/`, matching the authoring API corpus's +classification of intentionally unreadable modules. `negative/list-123.lex.tex` +is the boundary refusal. `negative/later-list-123.lex.tex` puts the same failure +after another declaration; the diagnostic's source span covers the module body +and does not pretend to name +the nested term. `split-list-200.lex.tex` demonstrates the advised workaround +with two 100-cell definitions. The case also calls the semantic JSON reader +directly and checks that its existing canonical and closed-schema refusals +remain intact. No verification claim is made by these checking fixtures. diff --git a/tests/semantic-json-depth/list-122.lex.tex b/tests/semantic-json-depth/list-122.lex.tex new file mode 100644 index 0000000000..4361519883 --- /dev/null +++ b/tests/semantic-json-depth/list-122.lex.tex @@ -0,0 +1,7 @@ +\begin{lexlean}{Main} +\useglossary{lexlean.std.nat@1.2.0} +\title{Natural number addition} +\begin{semanticmodule} +definition{ name: xs, parameters: [], result: (List Nat), body: (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (nil Nat))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) } +\end{semanticmodule} +\end{lexlean} diff --git a/tests/semantic-json-depth/negative/later-list-123.lex.tex b/tests/semantic-json-depth/negative/later-list-123.lex.tex new file mode 100644 index 0000000000..7636ca8f08 --- /dev/null +++ b/tests/semantic-json-depth/negative/later-list-123.lex.tex @@ -0,0 +1,8 @@ +\begin{lexlean}{Main} +\useglossary{lexlean.std.nat@1.2.0} +\title{Natural number addition} +\begin{semanticmodule} +definition{ name: first, parameters: [], result: (List Nat), body: (cons 1 (nil Nat)) } +definition{ name: later, parameters: [], result: (List Nat), body: (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (nil Nat)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) } +\end{semanticmodule} +\end{lexlean} diff --git a/tests/semantic-json-depth/negative/list-123.lex.tex b/tests/semantic-json-depth/negative/list-123.lex.tex new file mode 100644 index 0000000000..a38645d78d --- /dev/null +++ b/tests/semantic-json-depth/negative/list-123.lex.tex @@ -0,0 +1,7 @@ +\begin{lexlean}{Main} +\useglossary{lexlean.std.nat@1.2.0} +\title{Natural number addition} +\begin{semanticmodule} +definition{ name: xs, parameters: [], result: (List Nat), body: (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (nil Nat)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) } +\end{semanticmodule} +\end{lexlean} diff --git a/tests/semantic-json-depth/split-list-200.lex.tex b/tests/semantic-json-depth/split-list-200.lex.tex new file mode 100644 index 0000000000..73f2b9b465 --- /dev/null +++ b/tests/semantic-json-depth/split-list-200.lex.tex @@ -0,0 +1,9 @@ +\begin{lexlean}{Main} +\useglossary{lexlean.std.nat@1.2.0} +\title{Natural number addition} +\begin{semanticmodule} +definition{ name: chunkA, parameters: [], result: (List Nat), body: (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (nil Nat))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) } +definition{ name: chunkB, parameters: [], result: (List Nat), body: (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (cons 1 (nil Nat))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) } +definition{ name: xs, parameters: [], result: (List Nat), body: (prim append (chunkA) (chunkB) : (List Nat)) } +\end{semanticmodule} +\end{lexlean}