refactor: plan 6.5 frontend hardening and concise diagnostics - #20
Merged
Conversation
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Accept str instead of arbitrary byte buffers. Checked conversions prevent invalid string creation through the safe parser API. Signed-off-by: microproofs <kwhitemsg@gmail.com>
Use source-sized coordinates and checked protocol conversion. Preserve full diagnostic widths and reject Unicode code overflow. Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Plan 6.5: frontend hardening before Plan 07, plus the concise-diagnostics refactor. Two plan files: plans/frontend-hardening.md (eight chunks, one commit each) and plans/diagnostics-refactor.md (two commits). Verification record: docs/frontend-hardening-verification.md. Eleven commits, one per verified chunk.
Net: 801 files, +11,254 / −13,203. Production Rust across the inference pipeline drops from 21,208 to 20,574 lines; the
Constrainttree and the intermediate inferenceTypeare gone.Versioning: nine changesets. Minor bumps for
nash-region,nash-source,nash-parse,nash-can,nash-constrain,nash-solve,nash-driver,nash-report,nash-language-server,nash-cli; patch bumps where a crate is only touched incidentally. See.sampo/changesets/.Parser (
perf(parse),fix(parse)×3)Region). Growth is linear. Regression test checks operand count, full consumption and bounded growth.Parser::new(&bump, src: &str). All seven unchecked UTF-8 conversions replaced with checked ones. A compile-fail doctest rejects byte input. Snapshots for raw Unicode, mixed Unicode/escapes, CRLF normalization.Regionusesusize, bounded by the source allocation (isize::MAX), so no fallible constructor.Regiongrows from 8 to 32 bytes on 64-bit hosts; CLAUDE.md updated. LSP checks its 32-bit limit explicitly instead of truncating. Oversized Unicode escapes saturate as an invalid-code marker without integer overflow. Positions beyond 65,535 covered by CLI JSON tests.EXCESSIVE NESTINGat the first exhausted position. Flat sequences (access chains, lambda arguments, else-if, let definitions, case arms, union variants) and nested comments iterate. 512 parentheses previously aborted on a 2 MiB stack; tests run on that stack in debug and release.Driver, canonicalizer, solver (
refactor(driver),refactor(can),perf(types),refactor(types))InterfaceCache,ModuleMeta, load/save, serde derives and the cache-only error had no active caller.bincodeleaves the workspace. In-memoryInterface/Exportand fingerprint tests remain.Env. Shadowing, let-group visibility, free-variable bookkeeping and sorted suggestions unchanged; three baseline snapshots captured against the old implementation.ImplKeyrange helper (start at the trait with an empty head, stop when the trait changes). Equivalence regression compares every candidate key and payload against the old full-map filter across 18 combinations.nash-solve/src/solve/{infer,expressions,patterns}.rsinfer straight from the canonical AST into the existing union-find and predicate engine.nash-constrainkeeps union-find types, canonical instantiation and error types;expression.rs,pattern.rs,module.rsand the constraint tree are deleted. The driver passes the canonical module to the solver. Preserved: ranks, generalization, recursive groups, annotations, aliases, higher-kinded applications, representation predicates, deferred fields, ordered diagnostics, independent-error recovery,SolvedTypes/evidence contracts.NodeIds and unordered map iteration normalized. Twenty-two extra probes match.Diagnostics (
refactor(report),refactor(syntax))code/snippet.rsdeleted.code,severity,labels,suggestions,related. Messages no longer embed source drawings; consumers render the labels.docs/diagnostics.mdrewritten.Docs
docs/overview.md,docs/traits.md, SPEC.md describe the direct-inference pipeline, coordinate rules, scope borrowing and nesting limit.plans/06-diagnostics.mdlinks the refactor.Deferred
Test plan
cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningscargo insta test --workspace --check --unreferenced reject— 2,968 passed, 0 failed, 3 ignored; no pending or unreferenced snapshotscargo run -p nash-cli -- check tests/core— 23 modules, 215 declarationscargo test --release -p nash-parse— Unicode/escapes, coordinates beyond 65,535, lookahead, oversized escapes, nesting on a 2 MiB stack, long flat sequences (per verification record)https://claude.ai/code/session_01ScuAeUCfNGXAznfEEKDH1X