Skip to content

fix(lsp): fail closed on malformed requests; extend aspect gate to panic family - #117

Merged
hyperpolymath merged 1 commit into
mainfrom
arena/01a10483-vcl-ut
Oct 4, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
arena/01a10483-vcl-ut

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Closes #49.

What #49 asked, and where it stands

Re-audited all three items against the current tree (the gate has evolved since the issue was filed in June — it now scopes checks 2–3 to production code and accepts // SAFETY:-justified FFI, both correct refinements):

Issue item Disposition
5 missing SPDX headers Done (landed earlier, e.g. #116). Verified: 0 missing.
20 unsafe in src/ 10 remain, all justified: each carries a contiguous // SAFETY: comment; attest and recompute-wasm (the only crates with unsafe) both set #![deny(clippy::undocumented_unsafe_blocks)]. These are #[no_mangle] extern "C" FFI trust boundaries, which cannot be written without unsafe — elimination is impossible, documentation is the correct posture, and the gate enforces it.
61 unwrap/expect in src/ All remaining hits are test-only: every one sits inside a #[cfg(test)] module or under src/*/tests/ (plus testing.expect in Zig test files, out of the Rust gate's scope by design). Production count is 0.

The gate already passed 6/6 — but the audit found one genuine hole in the same SPARK-grade family that the gate didn't cover: a production panic!.

Changes

  • src/interface/lsp/src/main.rs — the request dispatcher panic!'d (crashing the whole server) when a request's method matched but its params failed JSON deserialization. It now answers JSON-RPC Invalid params (-32602) naming the method and the error, via a new three-outcome Cast type that rescues the request id before extract() consumes it. Also adds #![deny(clippy::unwrap_used, clippy::expect_used)], mirroring vclt-gate, and dedupes error responses through a new send_error helper.
  • tests/aspect_tests.sh — check 3 now also rejects panic!/unreachable!/todo!/unimplemented! in production src/, matching the documented vcltotal-parse SPARK-grade lint set (the estate pattern per parse/src/lib.rs).
  • src/interface/parse/src/parser.rs — one doc comment reworded (panic! → panic, meaning unchanged) so the textual gate stays precise.
  • CHANGELOG.adoc — [Unreleased] / Fixed entries.

Validation

  • bash tests/aspect_tests.sh → 6 passed, 0 failed (before and after; the gate is now strictly stronger).
  • Negative test: temporarily injecting panic!("boom") into production src/ makes the new check FAIL as intended; removed afterwards.
  • bash -n on the script and git diff --check clean.
  • Note: vcltotal-lsp is not built by standalone CI (it needs the echidna sibling path-dep; only the estate e2e layout compiles it), and this sandbox has no Rust toolchain — so the main.rs change was verified by inspection against the lsp-server 0.7 API on docs.rs (Request { pub id, pub method, pub params }, Request: Clone, extract signature, ExtractError::{MethodMismatch, JsonError { method, error }} shapes all confirmed). Only previously-unused-but-public API surface (req.id.clone()) is introduced; every other construct mirrors adjacent existing code.

Suggested follow-up (not in this PR)

Per-crate #![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, …)] on the remaining lib crates (lsp, dap, fmt, lint, attest, echidna-client) with allows in their test modules, mirroring vcltotal-parse. Deliberately left out: it needs cargo clippy validation per crate, which isn't available in this sandbox — and #49 itself warns against blind passes.

…nic family

The LSP server's request dispatcher panicked (crashing the server) when a
request's method matched but its params failed JSON deserialization. The
dispatcher now answers JSON-RPC Invalid params (-32602) naming the method
and the error, via a new three-outcome Cast type that rescues the request
id before extract() consumes it. The binary also gains
#![deny(clippy::unwrap_used, clippy::expect_used)], mirroring vclt-gate.

tests/aspect_tests.sh check 3 now also rejects panic!/unreachable!/todo!/
unimplemented! in production src/, matching the documented vcltotal-parse
SPARK-grade lint set; a parser.rs doc comment is reworded (panic! -> panic,
meaning unchanged) so the textual gate stays precise.

Disposition of #49: SPDX headers complete; remaining unsafe is confined to
// SAFETY:-justified FFI trust boundaries; remaining unwrap/expect is
test-only; last production panic! removed. Gate passes 6/6.

Closes #49.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 25bee442-ee39-44ef-a337-6f4540d4f413
📥 Commits

Reviewing files that changed from the base of the PR and between 9546eda and e317ece.

📒 Files selected for processing (4)
  • CHANGELOG.adoc
  • src/interface/lsp/src/main.rs
  • src/interface/parse/src/parser.rs
  • tests/aspect_tests.sh
 _______________________________________________
< Finding your faults 10 times faster than Mom. >
 -----------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • 🔴 Error committing to branch - (🔄 Check to retry)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hyperpolymath
hyperpolymath merged commit 5033607 into main Oct 4, 2026
184 of 190 checks passed
@hyperpolymath
hyperpolymath deleted the arena/01a10483-vcl-ut branch October 4, 2026 01:33

Copy link
Copy Markdown
Owner Author

CI verification (for the merger)

All checks covering this change pass: Aspect tests, vcltotal-parse (clippy/tests), license-policy, Licence consistency, Root workspace tests, attest / recompute-wasm clippy+tests, CodeQL, secret scanners, Semgrep, OpenSSF.

The 5 remaining red checks were each verified pre-existing on main at the base commit 9546eda (identical job, identical conclusion) — zero regressions from this PR:

Check PR #117 main @ 9546eda
rust-ci / Cargo check + clippy + fmt failure failure (run 37154179619)
governance / Workflow security linter failure failure (run 37154179580)
Hypatia neurosymbolic scan (Static Analysis Gate) failure failure (run 37154179050)
Validate K9 contracts (Dogfood Gate) failure failure (run 37154179093)
Dependency audit (cargo-audit) failure failure (run 37154179103)

(These match the pre-existing reds already documented in #116. Backend-matrix Smoke jobs still pending at time of writing are unrelated to this change.)

On merge, Closes #49 takes effect; the Aspect gate re-runs on main via e2e.yml.

@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create Coding Agent finishing-touch task. Please try again.

@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Autopilot could not be updated. Open Coding to check access and billing.

hyperpolymath added a commit that referenced this pull request Oct 5, 2026
…49) (#121)

Follow-up to #49 / #117. #117 allowed *documented* `unsafe` in `src/`;
this PR enforces the stricter boundary #49 asked for: **no unsafe Rust
under `src/` at all**, with the FFI boundary crates moved to
`ffi/rust/`.

## Changes
- `git mv src/interface/{attest,recompute-wasm} ffi/rust/`; path deps →
`../../../src/interface/parse`; lockfiles unchanged.
- `tests/aspect_tests.sh` (keeps #117's unwrap/expect/panic-family
check):
- no `unsafe {` / `unsafe fn|impl|trait|extern` / `#[unsafe(..)]` /
`static mut` anywhere under `src/` (tests included)
- `#![forbid(unsafe_code)]` on every `src/` crate root (`lib.rs`,
`main.rs`, `src/bin/*.rs`)
  - SPDX identifier on line 1 of every `src/` Rust file
- `target/` pruned from every scan; failures now name the offending file
- Added `forbid(unsafe_code)` to 9 crate roots; moved misplaced SPDX
headers (dap/fmt/lint/lsp); `rustfmt` on `vcltotal-parse`.
- Paths followed in `ffi/zig/build.zig`, `satellite-crates-gate.yml`,
`dependabot.yml`, `audits/assail-classifications.a2ml`, `REUSE.toml`
(`ffi/**`), ADR-0002, VERIFICATION-STANCE, PROOF-NEEDS,
Tier2/Foreign.idr; new `ffi/rust/README.adoc`.

## Verified locally (cargo 1.97.1, zig 0.16.0)
- `tests/aspect_tests.sh`: 7/7 pass. Positive controls: a planted
`unsafe {}`, `#[unsafe(no_mangle)]`, `static mut`, `unsafe impl`, a
misplaced SPDX line, and a removed forbid each FAIL the right check; a
comment mentioning `unsafe {` and an `unsafe_code` identifier do not.
- `ffi/rust/attest`: clippy `-D warnings` clean, 9 tests pass.
`ffi/rust/recompute-wasm`: clippy clean, 3 tests pass.
- `src/interface/parse`: clippy clean, all tests pass with
`RUST_MIN_STACK=32MiB` (as in `parse-gate.yml`). Without it,
`wire::op_roundtrip` intermittently overflows the default stack: an
existing proptest-depth issue that CI already handles.
- Root workspace: clippy `-D warnings` clean, 102 tests pass; `cargo fmt
--check` clean.
- `ffi/zig`: `zig build test` passes, linking the attest staticlib from
its new path.
- `reuse lint`: compliant, 479/479.

- `Dependency audit` (also red on main): bumped `crossbeam-epoch` 0.9.18
→ 0.9.21 in the root `Cargo.lock` for RUSTSEC-2026-0204. `cargo audit`
is now clean apart from the allowed `anyhow` warning RUSTSEC-2026-0190.

- `governance / Workflow security linter` (also red on main): moved the
SPDX header of `rhodibot.yml` to line 1, below which the actions-lock
marker now sits.
- CodeRabbit autofix commits `73c8a98` (split-line `unsafe` detection,
confirmed with planted controls) and `a37ecf3` (docstrings) reviewed and
kept.

Recut of the 2026-10-03 patch `53e80b4` onto current main.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aspect gate: SPARK-grade source refactor (SPDX + eliminate unsafe / unwrap / expect in src/)

1 participant